0

i just want an application through which i can dynamically assign roles to users through check boxes. Any answer will be appreciated.

Thanks

Mohd Anas
  • 634
  • 1
  • 9
  • 22
  • Just a thought: Consider that a "role" is typically associated with a set of permissions, and that set can really have any number of associated permissions, including one. So any RBAC system can conceivably have roles that each map directly to one permission. I don't know much about any of the technologies referred to in the tags, so i'm not sure what you'd be looking for outside of that. – cHao Oct 19 '12 at 07:29
  • hey mohd have you solved your problem ? i want to make the same of your question but i don't know how... – Mostafa Hussein Sep 05 '13 at 04:21

1 Answers1

1

There is this gem "cancan" by Ryan Bates.

https://github.com/ryanb/cancan

It integrates nicely with Devise for authentication as well.

Read this 2 - part tutorial.

http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/

class Ability
  include CanCan::Ability
  def initialize(user)
if user.admin?
  can :manage, :all
else
  user.permissions.each do |permission|
    can permission.action_name.to_sym, permission.object_type.constantize # Getting the class name
  end
end
end
end

This would now dynamically create permissions for the user. Does this help?

Nerve
  • 6,463
  • 4
  • 29
  • 29
  • i have followed this link but this is for static role means you can just tick the check box that you are admin or operator or whataever you are i want to customize the user's view like i want the matrix of check boxes in the views in which user can tick many check boxes like read,edit,destroy and i dont want to work on ability class..ability class will be maintain dynamically..i hope you understand – Mohd Anas Oct 19 '12 at 12:00