hello,
i would like to display a collection of records on one page (e.g. an
author record with all his/her books).
a record contains a text_area (e.g. a description of the book) and a
date_select (e.g. when the book was published).
<% for @book in @author.books %>
<%= text_area ‘book[]’, ‘note’ %>
<%= datetime_select ‘book[]’, ‘published_on’ %>
<% end %>
the text_field works nice, the generated code looks like:
foo
the ID of a book record is there.
BUT i do not know, how to achieve this with the date_select helper?
the helper generates:
00</option
...
it should be name="book[12][published_on(2i)]"
how to do that? (:prefix, :discard_type did not work for me)
thanks
ondrej
Ondrej Jaura wrote:
it should be name=“book[12][published_on(2i)]”
how to do that? (:prefix, :discard_type did not work for me)
As the core code is currently written, you can’t use either auto or
explicit indexing with date_select. You’ll have to use select_year,
select_month, and select_day, using @book.published_on as their dates,
prefix options set to “book[#{@book.id}]”, and field_name options
‘published_on(1i)’, ‘published_on(2i)’, and ‘published_on(3i)’.
–
We develop, watch us RoR, in numbers too big to ignore.
Mark Reginald J. wrote:
<option value="00">00</option
prefix options set to “book[#{@book.id}]”, and field_name options
‘published_on(1i)’, ‘published_on(2i)’, and ‘published_on(3i)’.
thanks :)
have a nice day
ondrej