I'm using cancan in a Rails 3.2 app, and in the abilities.rb classing have a method for each role's abilities
#ability.rb
def initialize(user)
user_or_admin ||= User.new
user.roles.each do |role|
send(role.name)
end
end
def role_name_a
end
def role_name_b
end
Some of these methods require access to the user record, how do I pass it with the send function?
e.g. I want to do something like
send(role.name)(user)
and then
def role_name_a(user)
But this doesn't work. Grateful for any ideas.