On Dec 4, 6:58 pm, Vasu Kottilil <[email protected]> wrote:
>
> {"commit"=>"Create",
>  "authenticity_token"=>"1459525ad4fd5ae39be0c011edc5c45fdbff4337",
>  "user"=>{"work_phone"=>"",
>  "address"=>{"address1"=>"ad1",
>  "city"=>"any town",
>  "address2"=>"line2",
>  "zip"=>"12345",
>  "country"=>"USA",
>  "state"=>"CA"},
>  "profile_name"=>"pfname",
>  "home_phone"=>"",
>  "cell_phone"=>"",
>  "last_name"=>"last",
>  "first_name"=>"first",
>  "email"=>"",
>  "active"=>"1"}}
>
> It is a simple 1-1 relationship - each user has one address. In this
> use case I am trying to create data in two tables using a single
> form.

your code looks like you expect params[:address] to be set, but it
isn't (instead params[:user][:address] is set).
Rails is then trying to do user.address = params[:user][:address]
which doesn't work because you're trying to stuff a hash into an
association. It can be made to work with the nested attributes stuff
but that's only in rails 2.3. You could change your views to not
submit parameters in this way or read up on nested attributes.

Fred
>
> I am certain that I am missing some more code that is required to
> successfully save. Any clues greatly appreciated. Any suggestions to
> implement in a different way are welcome.  Can I explicitly write ruby
> code to insert records into these tables even though I created the
> objects using the rails scaffolding?
>
> Thanks much
>
> Vasu Kottilil

--

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