Drop downs for new and edit

I have a drop down in my forms.

Year Manufactured The value needs to be from 1970 -- current year

In the new form i am using the following code

<select name="vehicle[year_made]" id="vehicle_year_made">
<option value="0" selected="selected">-- Select --</option>
<%= options_from_collection_for_select((1970..Time.now.year).collect
{|p| [ p, p ] }, "first", "last") %>
</select>

You could use select_year

Fred

You could use select_year

Fred

I am sorry I do not know ruby as much so will need more help than
this.

You could start by reading the api docs (http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001677
  )

Fred

You could start by reading the api docs
(http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001677
  )

Fred

Thanks for this, now two more questions remain.

I still need to have a custom value like -- Select -- added in there.

And also for edit time, how do i make it that it shows the value from db
already selected?

You could start by reading the api docs
(http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001677
)

Fred

Thanks for this, now two more questions remain.

I still need to have a custom value like -- Select -- added in there.

And also for edit time, how do i make it that it shows the value
from db
already selected?

Both of those are covered by the examples in the api docs I linked to.

Fred

Both of those are covered by the examples in the api docs I linked to.

Fred

Thanks for the help so far, but using this i am running into more issues
that before, I am not getting the field name as i want it using
:field_name to specify the vehicle[year_made] gives me
date[vehicle[year_imported]] and also the prompt does not show.

So guiding me to the API is not helping me solving my problem. Any other
solutions.

Both of those are covered by the examples in the api docs I linked
to.

Fred

Thanks for the help so far, but using this i am running into more
issues
that before, I am not getting the field name as i want it using
:field_name to specify the vehicle[year_made] gives me
date[vehicle[year_imported]] and also the prompt does not show.

you need to play with the the :prefix option to change date to
something else.

Fred