DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use Rails Date_select Without Activerecord Model

10.10.2007
| 30893 views |
  • submit to reddit
        // In your view:
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>

// In your controller:
@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)

Credit: http://www.jonsthoughtsoneverything.com/2006/05/21/how-to-access-date_select-without-an-active-record-model/