gem 'cancancan' rails generate cancan:ability //in controller load_and_authorize_resource //ability def initialize(user) user ||= User.new can :manage, :all, user_id: user.id if user.role == 'user' can :read, Recipe, public: true end
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter