Ruby on Rails サイトを作成し、最近追加したもの:
<% if (?can :manage, :table) %>
<%= link_to 'New Table', new_table_path %>
<% end %>
いくつかの追加のセキュリティのために、今ではこれを行うことができないと述べています。私はそれが私の能力と関係があるかもしれないと思います:
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
助けてくれてありがとう。追加のコードが必要な場合はお知らせください。