Hello,
I have a roles table, permissions table and a rights join table. I
have has_many :through relationships between the two tables.
Roles Permissions Rights table
id name id name role_id permission_id
1 User 1 posts/new 1 2
2 Admin 2 posts/create 2 2
In the admin side of the app I create new roles and permissions. But I
wanted to be able to assign values to the rights table in an easy way,
so I created a rights controller and a view to show the current values
and assign new permission to certain roles via checkboxes.
Permissions User Admin
posts/new <checkbox> <checkbox>
posts/edit <checkbox> <checkbox>
posts/destroy <checkbox> <checkbox>
posts/create <checkbox checked> <checkbox checked>
I have some code on my view where I save the permission_ids selected
onto a hash, but I''ll like to save the roles_ids too. How can I post
both of them to save them later on the controller in the rights table?
The problem that I have is that I can post a hash of permission_ids,
but I also need the role_ids hash. The examples I have looked at only
need to post one hash and the other value needed to fill the join
table is the current_user id. In this case I need permission and role
ids. Any ideas on how to post this values into the controller?
Portion of my view
<% for permission in Permission.find(:all, :order => "name
ASC")
%>
<tr class=<%=
cycle(''even'',''odd'') %>>
<td><%=h permission.name %></td>
<% for role in Role.find(:all) %>
<td><%= check_box_tag "right[permission_ids][]",
permission.id, permission.roles.include?(role) %></td>
<% end %>
</tr>
<% end %>
Thanks!
Elioncho
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---