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> 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Feb 2009, at 12:42, Qaiser Wali wrote:> > 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> 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? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> On 3 Feb 2009, at 12:42, Qaiser Wali wrote: > > You could use select_year > > FredI am sorry I do not know ruby as much so will need more help than this. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 (http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001677 ) Fred> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > You could start by reading the api docs > (http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001677 > ) > > FredThanks 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Feb 2009, at 13:03, Qaiser Wali wrote:> >> >> 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> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Both of those are covered by the examples in the api docs I linked to. > > FredThanks 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Feb 2009, at 13:44, Qaiser Wali wrote:> >> 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> So guiding me to the API is not helping me solving my problem. Any > other > solutions. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---