hi, i am new to Roby on Rails. we have a project on this. i have very much satisfied with development with this environment. it is very iteresting. but i have a problem with insertion. my problem is: i have to insert values into two tables at one submit. i am using mysql as db. i have created two tables which has one to one reelation ship. once i enter name and email address and role. name and emailaddress has to be inserted in users table. with that id role is to be inserted in user_roles table.can any help me in this. -- Posted via http://www.ruby-forum.com/.
Nathaniel Brown
2006-Aug-03 17:48 UTC
[Rails] inserting values in two tables at one button click
Have your forms build the data for two tables. <%= text_field ''modelOne'', ''column %> <%= text_field ''modelTwo'', ''column %> --- Controller Action ModelOne.new(params[:modelOne]).save ModelTwo.new(params[:modelTwo]).save That is a super simplified way of doing it. You might want to have some checks on save, and validations and such. -NSHB On 8/3/06, Ks Ben <kspt_b@rediffmail.com> wrote:> > hi, i am new to Roby on Rails. we have a project on this. i have very > much satisfied with development with this environment. it is very > iteresting. > but i have a problem with insertion. my problem is: i have to insert > values into two tables at one submit. > i am using mysql as db. i have created two tables which has one to one > reelation ship. once i enter name and email address and role. name and > emailaddress has to be inserted in users table. with that id role is to > be inserted in user_roles table.can any help me in this. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kind regards, Nathaniel Brown President & CEO Inimit Innovations Inc. - http://inimit.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060803/3d0265a7/attachment.html
Rein Henrichs
2006-Aug-04 17:20 UTC
[Rails] Re: inserting values in two tables at one button click
Ks Ben wrote:> hi, i am new to Roby on Rails. we have a project on this. i have very > much satisfied with development with this environment. it is very > iteresting. > but i have a problem with insertion. my problem is: i have to insert > values into two tables at one submit. > i am using mysql as db. i have created two tables which has one to one > reelation ship. once i enter name and email address and role. name and > emailaddress has to be inserted in users table. with that id role is to > be inserted in user_roles table.can any help me in this.It sounds to me like your real issue is database normalization. Is there a compelling reason to repeat the data like this? -- Posted via http://www.ruby-forum.com/.