GithubHelp home page GithubHelp logo

sun's Introduction

README

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Ruby version

  • System dependencies

  • Configuration

  • Database creation

  • Database initialization

  • How to run the test suite

  • Services (job queues, cache servers, search engines, etc.)

  • Deployment instructions

  • ... *Dutavi-sun

sun's People

Contributors

dutavi avatar huannd-0028 avatar

Watchers

 avatar

sun's Issues

Current user can only Delete,Edit their phrase

Why

This user cannot delete other people's phrases

How

Phrases
belongs_to :user
User
has_many :phrase

here:

before:

before_action :phrases_owner, only: [:edit, :update, :destroy]

affter :

def phrases_owner
    unless @phrase.user_id == current_user.id
      flash[:notice] = 'Access denied as you are not owner of this Phrases'
      redirect_to phrases_path
    end
  end

Definition of Done

  • Implement the code of God

Reference

https://stackoverflow.com/questions/41150707/ruby-on-rails-how-to-allow-only-current-user-to-edit-and-delete-posts-they-have

.

Feature

Current user can only Delete their phrase

Why

This user cannot delete other people's phrases

How

Phrases
belongs_to :user
User
has_many :phrase

here:

    <td><% if current_user.id == @post.user_id %></td>
    <td><%= link_to 'Edit', edit_post_path(@post) %></td>
    <td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
    <% end %> ruby

Definition of Done

  • Implement the code of God

Reference

https://stackoverflow.com/questions/41150707/ruby-on-rails-how-to-allow-only-current-user-to-edit-and-delete-posts-they-have

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.