Hi Rodrigo,
The boolean accessors on the User model could probably be refactored,
but you get the idea.
class User < ActiveRecord::Base
has_many :roles
def institution_admin?
roles.any? { |r| r.label == 'institution_admin' }
end
def system_admin?
roles.any? { |r| r.label == 'system_admin' }
end
end
class InstitutionController
allow_accesss(:system_admin)
allow_accesss(:institution_admin) do
@authenticated.institution == @institution
end
prepend_before_filter :find_institution
private
def find_institution
@institution = Institution.find(params[:id])
end
end
Can we continue this discussion on Ruby on Rails: Talk? This list is
meant for discussions about Ruby on Rails core development.
Manfred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---