Thanks for the input. That does prevent the error but it does not
actually update the roles_users join table that is a part of the habtm
association between User and Role.

I just tried this code within Create and it seems to work:...
 @user = User.new(params[:user])
 @user.roles.build(params[:role])

However, I have a question still. I was assuming that the Roles table
would not actually have a new record added when saving an habtm assoc.
model. I assumed only the join table and the Users table would be
updated. Otherwise it seems as though I would have a lot of redundant
data in my Roles table. Am I misunderstanding something here?

Thanks heaps




On Mar 18, 9:30 am, "[email protected]" <[email protected]> wrote:
> On 18 Mar., 14:20, elliottg <[email protected]> wrote:
>
> > When I implement this line:
> > �...@user = User.new(params[:user], :role => [ Role.new(params[:role]) ])
>
> > I get this argument error.
> >   ArgumentError in UsersController#create
> >   wrong number of arguments (2 for 1)
>
> > Any thoughts?
>
> > Thanks
>
> The #new method only accepts one argument. Do this instead:
>
> @user = User.new(params[:user].merge(:role => Role.new(params
> [:role])))
>
> --
> Cheers,
> David Knorrhttp://twitter.com/rubyguy
--~--~---------~--~----~------------~-------~--~----~
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 [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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to