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: nil > How 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? or realty.agency_id == nil or realty.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+unsubscr...@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/62b36cef-d004-42d8-b037-2573020a1cf3%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.