Hi All,
I want to enter parameters in 2 tables which are submitted using one
form.
Following is the relation of models.
In UserInfo.rb
has_one :user
validates_associated :user
validates_presence_of :city
In User.rb
belongs_to :user_info
validates_presence_of :first_name
I write following code in my UserInfosController
@user_info = UserInfo.new(params[:user_info])
@user_info.build_user(:first_name=>'') # which i'll modify later
@user_info.save
now if i click the submit button w/o entering any values i.e.
params[:userinfo][:city]=""
it gives me two error
* City can't be blank
* User is invalid
but i want second error should be as follows
*first name can't be blank
I would like to know how to do it or is there any other way in rails to
enter data into two tables using one form.
Regards,
Salil Gaikwad
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---