这是我的 CanCan 设置:
if user.college_coach?
can :read, Coach, :id => user.id
can :update, Coach, :id => user.id
can :update_billing_information, Coach, :id => user.id
can :update_account_type, Coach, :id => user.id
can :edit_account, Coach, :id => user.id
can :access_roster_builder, Coach, :id => user.id, :account_type => { :name => ["Recruiter", "Team", "Free"] }
can :access, Coach, :college_dashboard
can :access_saved_profiles, Coach, :id => user.id, :account_type => { :name => ["Team"] }
can :access_draftboard, Coach, :id => user.id, :account_type => { :name => ["Team"] }
can :update, Draftboard, :coach_id => user.id
can :access_contributors, Coach, :id => user.id, :account_type => { :name => ["Team"] }
can :access_deleted, Coach, :id => user.id, :account_type => { :name => ["Team"] }
can :save_searches, Search, id: user.id, account_type: { name: ["Recruiter", "Team"] }
can :read, Athlete
can :update, Athlete
can :update_account_type, Athlete
can :keep, Athlete
can :draft, Athlete
can :share, Athlete
can :notes, Athlete
can :contact, Athlete
can :cut, Athlete
can :read, Stat
can :view, :social_box
end
在我看来:
<% if can?(:save_searches, Search) %>
<input type="button" class="blk-button hide search-related" id="save-to-pdf" value="Save Results to a PDF" />
<% end %>
即使我将用户的帐户类型更改为免费帐户类型,该按钮仍会显示...不确定是什么原因导致此功能不起作用..