Reputation: 56719
I have just started with CanCan and here's a sample of the code:
# Ability.rb
def initialize(user)
user ||= User.new
can :read, Link
end
# view.html.erb
<% if can? :read, @link %>
...
<% end %>
This is from the github repo for CanCan but this doesn't seem to work (it returns false and stops the ...
code from running).
When I change the view to <% if can? :read, Link %>
, it works. But, this is different to the CanCan readme. Do you know where I'm going wrong here?
Upvotes: 0
Views: 370
Reputation: 40277
can? :read, Link
is the concept of a link... something to the akin of "Can you read all links?"
can :read, Link do |link|
link.account.id == user.account_id
end
This checks to make sure you can read the specific link object in question
Upvotes: 0
Reputation: 25994
Check that
Upvotes: 1