Ruby on Rails
Monday, February 17, 2014
On Sunday, February 16, 2014 10:57:33 PM UTC-6, Роман Ярыгин wrote:
Hello everyone!I have code:if user.role == "topmanager"can :read, ActiveAdmin::Page, :name => "Dashboard"can :manage, Realty, agent: {agency_id: user.agency_id}...And I want to add another condition, can :manage, Realty, agent: nilHow to do it? Defining it two times gets error:undefined method `reflect_on_association' for Class:Class
How can I define multiple conditions for one ability?
You can use the 'or' & 'and' operators in the ability class.
can :manage, Realty do |realty|realty.new_record? orrealty.agency_id == nil orrealty.agency.agents.include?(user)
end
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8ff0713a-a840-4a41-b544-f4edae3e7a65%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment