How to get a Date from date_select or select_date in Rails?
问题 Using select_date gives me back a params[:my_date] with year , month and day attributes. How do get a Date object easily? I\'m hoping for something like params[:my_date].to_date . I\'m happy to use date_select instead as well. 回答1: Using date_select gives you 3 separate key/value pairs for the day, month, and year respectively. So you can pass them into Date.new as parameters to create a new Date object. An example date_select returned params for an Event model: "event"=> {"name"=>"Birthday",