Monday, May 16, 2011

[Rails] select_tag form_for conventions

Hi guys,

I wonder if I am missing some conventions for the select_tag.

In fact, while the f.text_field is automatically naming the html text
field form_name[field_name] just using the :field_name convention,
like:

<div>
<%= f.label :data_point_id %>
<%= f.text_field :data_point_id %>
</div>

if I try to display a select_tag for the same attribute I have to use
a select_tag, since there is no f.select_tag, I have to include the
form_name inside the select_name, like this:

<div>
<%= f.label :data_point_id %>
<%= select_tag 'data_point_tab[data_point_id]',
options_from_collection_for_select(DataPoint.all, 'id', 'name')%>
</div>

Is there a better way to do this or am I doing correct?

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate