Re: About a simple insert

Bob Showalter
Tue, 15 May 2007 15:45:00 -0000

On 5/15/07, Matthew Lagace
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> Ok i got that, but in my new.rhtml, what do I put in the value field of
> my text input? I tried <%= @client.details.name %> but it
doesn''t work.

Oh, I see what you''re saying.

You should keep two separate objects for the purpose of the form:

(in controller)

   @client = Client.new
   @detail = Detail.new

Then in the view:

   <%= text_field :detail, :name %>

Before the save, you would add the detail to the client:

   @client.details << @detail
   @client.save