Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

How to handle permission in rails

class Ability
  include CanCan::Ability

  def initialize(user)
    if user.present?  # additional permissions for logged in users (they can read their own posts)
      can :read, Post, users: { id: user.id }
    end
  end
end
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #handle #permission #rails
ADD COMMENT
Topic
Name
4+4 =