Just another question that may help me better understand habtm workings...
Would it be true that in order to create a fully functional habtm record that both models using the habtm assoc. need to be updated and saved? Or is it possible to do having a fully working relationship by saving only one of the two? Thanks On Mar 18, 10:04 am, elliottg <[email protected]> wrote: > 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]) > �[email protected](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 -~----------~----~----~----~------~----~------~--~---

