Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't mass-assign protected attributes: group_ids #16

Closed
farviewsoft opened this issue Mar 20, 2012 · 4 comments
Closed

Can't mass-assign protected attributes: group_ids #16

farviewsoft opened this issue Mar 20, 2012 · 4 comments
Labels

Comments

@farviewsoft
Copy link

I just downloaded and installed the master branch of boxroom and everything runs fine except when I try to assign a group to a user. When I create a new group then go to edit the user and check a new group to add then click save, I get the following exception:


Can't mass-assign protected attributes: group_ids
Rails.root: /opt/development/boxroom

Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:31:in `update'
Request

Parameters:

{"commit"=>"Save",
 "authenticity_token"=>"rNQ6kd+x+QKIWvJaLNEUQzXROGT1cVSlrZ34Yzax0YY=",
 "_method"=>"put",
 "utf8"=>"\342\234\223",
 "id"=>"1",
 "user"=>{"name"=>"admin@example.com",
 "password_confirmation"=>"[FILTERED]",
 "group_ids"=>["2"],
 "password"=>"[FILTERED]",
 "email"=>"admin@example.com"}}
Show session dump

Show env dump

Response

Headers:

None```
mischa78 added a commit that referenced this issue Apr 10, 2012
@mischa78
Copy link
Owner

I just fixed this bug. Please try again :-)

@edwardsharp
Copy link

I had this same issue but this fix did not work for me. I just added :group_ids to the attr_accessible list in app/models/user.rb and now I can create users...

@edwardsharp
Copy link

Actually, line 18 of the groups_controller.rb file that calls the set_groups function in the create method has the wrong number of arguments (0 for 1), so to get this totally working I needed to comment that out, too.

@mischa78
Copy link
Owner

@edwardsharp I don't think it's a good idea to just add :group_ids to the attr_accessible list. This may e.g. allow someone who is not an admin to add themselves to an admins group. I am doing this trough set_groups, so I can check that the user is allowed to update groups. Anyway, I fixed it in the create method too. Everything should be OK now. Thanks for your feedback!

mischa78 added a commit that referenced this issue Apr 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants