Creating a ruby on rails site and recently added:
<% if (?can :manage, :table) %>
<%= link_to 'New Table', new_table_path %>
<% end %>
for some additional security and now it states that I cannot do this. I think it might have something to do with my abilities which are:
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
if user.role? "admin"
can :manage, :all
end
def initialize(user)
user ||= User.new
can :read, :all
if user.role? "coach"
can :manage, :all
end
def initialize(user)
user ||= User.new
can :read, :all
if user.role? "captain"
can :manage, :tournaments
can :manage, :results
end
def initialize(user)
user ||= User.new
can :read, :all
if user.role? "teammember"
can :manage, :individualresults
end
end
end
Thanks ahead for any help. If you want additional code let me know.
Your ability file should probably look like:
Checking a user action against the defined CanCan rules is done like: