【发布时间】:2014-04-13 21:48:16
【问题描述】:
我在 Ruby 1.8.7 和 Rails 2.3.8 中有一个哈希:
important_dates = params[:important_dates]
important_dates =#>
{"third_test"=>"July 11, 2014", "fourth_test"=>"August 08, 2014", "second_test"=>"June 13, 2014", "sixth_test"=>"August 05, 2014"}
日期来自 Rails 中的 calendar_select_date_tag,我将日期对象传递给它,但在参数中,当我尝试这样做时,我总是得到一个字符串:
new_dates = important_dates.each_value{|r| r.to_date}
new_dates[:fourth_test].class.inspect #=> String
我已经做了好几个小时了。
【问题讨论】:
标签: ruby-on-rails ruby datetime type-conversion hash