Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created March 14, 2010 02:54
Show Gist options
  • Save lxneng/331737 to your computer and use it in GitHub Desktop.
Save lxneng/331737 to your computer and use it in GitHub Desktop.
Use rails date_select without activerecord model
#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)
#view
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>
@jackcompton
Copy link

And if you want to keep the value in that date select after submit.. ad the following line to your controller

@range = Struct.new(:start_date).new(@start_date)

@lxneng
Copy link
Author

lxneng commented Sep 21, 2011

thanks!~ good solution!~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment