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 -- <%= options_from_collection_for_select((1970..Time.now.year).collect {|p| [ p, p ] }, "first", "last") %>

I want to be able to show the items in reverse order. Where the most
recent year shows first.

Also in the edit form i want similar code but with the selected item to
be the one that is present in the database. How can i achieve this?

On 3 Feb 2009, at 12:42, Qaiser Wali wrote:

{|p| [ p, p ] }, “first”, “last”) %>

You could use select_year

Fred

On 3 Feb 2009, at 12:42, Qaiser Wali wrote:

You could use select_year

Fred

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

On 3 Feb 2009, at 12:55, Qaiser Wali wrote:

On 3 Feb 2009, at 12:42, Qaiser Wali wrote:

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
(ActionView::Helpers::DateHelper
)

Fred

On 3 Feb 2009, at 13:03, Qaiser Wali wrote:

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.

On 3 Feb 2009, at 13:44, Qaiser Wali wrote:

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

You could start by reading the api docs
(ActionView::Helpers::DateHelper
)

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?