View helpers and nested attributes

Hello all,

I have a model with two entities (document and asset) and a 1:1
relationship defined between them (every model has an asset).

I want to generate a rthml view that generates a hash for document
attributes and a nested hash for asset attributes (for example
{:document =>{:name=>XXX :asset => {date =>XXX}})

According to the Pragmatic Programmers book (page 355), the input fields
for this should be something like

The question is: how can i generate the second field with the rails
helpers. I have tried:

<%=text_field “document” “asset[name]” %>
<%=text_field “document” “asset.name” %>

Is it possible to generate this kind of nested fields with helpers or
should I generated by hand?

Thanks in advance,

Rubén
extreme development, S.L.
Paseig del Ferrocarril 335, Planta 3
08860 Castelldefels

Tel. 93 145 87 20
Fax. 93 145 87 21

Rubén Gil wrote:

The question is: how can i generate the second field with the rails
helpers. I have tried:

<%=text_field “document” “asset[name]” %>
<%=text_field “document” “asset.name” %>

Is it possible to generate this kind of nested fields with helpers or
should I generated by hand?

Three options:

  1. Manual HTML
  2. The text_field_tag helper, overriding the id tag if necessary
  3. Install the Rails patch at http://dev.rubyonrails.org/ticket/2053


We develop, watch us RoR, in numbers too big to ignore.

Mark,

Thank you very much for your help.

Rubén Gil

extreme development, S.L.
Paseig del Ferrocarril 335, Planta 3
08860 Castelldefels

Tel. 93 145 87 20
Fax. 93 145 87 21

-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de Mark Reginald
James
Enviado el: sábado, 03 de diciembre de 2005 15:14
Para: [email protected]
Asunto: [Rails] Re: View helpers and nested attributes

Rubén Gil wrote:

I have a model with two entities (document and asset) and a 1:1
relationship defined between them (every model has an asset).

I want to generate a rthml view that generates a hash for document
attributes and a nested hash for asset attributes (for example
{:document =>{:name=>XXX :asset => {date =>XXX}})

According to the Pragmatic Programmers book (page 355), the input
fields

Is it possible to generate this kind of nested fields with helpers or
should I generated by hand?

Three options:

  1. Manual HTML
  2. The text_field_tag helper, overriding the id tag if necessary
  3. Install the Rails patch at http://dev.rubyonrails.org/ticket/2053


We develop, watch us RoR, in numbers too big to ignore.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails