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.
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 [email protected] wrote:
–
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Kind regards,
Nathaniel B.
President & CEO
Inimit Innovations Inc. - http://inimit.com
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?