2009/10/2 adedip <[email protected]>: > > > > On 2 Ott, 18:20, adedip <[email protected]> wrote: >> Thanks again to Peter..that's what I missed.. i need to call YEAR >> (date) even on the attribute side..not only for the variable.. :S >> thanks! >> I'll try >> >> On 2 Ott, 18:04, Colin Law <[email protected]> wrote: >> >> > 2009/10/2 adedip <[email protected]>: >> >> > > or maybe I'm wrong about the type... >> > > here's the form code in the view: >> >> > > <% @source = Article.find(:all) %> >> > > From: >> > > <%= collection_select("from", "date", @source, "date","date", >> > > {:include_blank => true}) %> >> > > To: >> > > <%= collection_select("to", "date", @source, "date","date", >> > > {:include_blank => true}) %> >> >> > If you are using params[:from] then it is a string. params[] are >> > always strings. The fact that you keep saying it is in yyyy-mm-dd >> > format does not make sense if it is a Date as a Date is not in a >> > particular format till you convert it to string for display for >> > example. >> >> that's what I've realized few minutes ago :P >> >> so >> params[:from].to_date >> would do the job?! > or maybe > > from = Date.new(params[:from]) >
Check the docs for Date. You might have to use strptime or one of the other constructor methods. Make sure you catch exceptions if converting from user typed input. Colin --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

