>
> i found this through google
>
> "The create and build methods are only available for has_one/
> belongs_to if an association already exist. It will not work when it's
> nil. "
>
> http://dev.rubyonrails.org/ticket/535
>
> though this is really a old post i dont know that it is solved or
> not.
>
Well, doing their suggestion works.
def new
@content_master = ContentMaster.new
@content_master.metadata = Metadata.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @content_master }
end
end
Then just use @content_master.metadata in your new.html.erb or reassign it
to @metadata, e.g.:
@metadata = @content_master.metadata = Metadata.new
The association is set up when you assign it to @content_master.metadata so
you don't need to call build from the nil object.
Cheers,
Andy
--
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.