我试图使用内置的ruby助手进行日期时间选择,虽然它似乎没有将值传递给ActiveRecord
form.haml.html
.row
.two.columns
= f.label :date_and_time, :class =>'left inline'
.ten.columns
= f.datetime_select('datetime', :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}, :order => [:day, :month, :year])
控制台输出
Processing by EventsController#update as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"sebpDgAPPmK8q9024vrhN4eEQT7vZLr+pa5XdSicAMc=", "event"=>{"event"=>"1", "location_id"=>"13", "datetime(3i)"=>"5", "datetime(2i)"=>"5", "datetime(1i)"=>"2012", "datetime(4i)"=>"01", "datetime(5i)"=>"03", "duration"=>"34", "arrival_time"=>"34", "team_id"=>"1", "opponent_id"=>"4", "home_or_away"=>"Away"}, "commit"=>"Update Event", "id"=>"68"}
User Load (1.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 38 LIMIT 1
Event Load (0.8ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", "68"]]
CACHE (0.0ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", "68"]]
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."team_id" = 1
(0.4ms) BEGIN
(0.9ms) UPDATE "events" SET "updated_at" = '2013-02-09 11:44:24.830499', "selected_players" = '---
- ''''
' WHERE "events"."id" = 68
(8.2ms) COMMIT
答案 0 :(得分:1)
根据您的标签,它是您数据库中的:date_and_time
字段,对吧?如果是这样,您应该在datetime_select
:
= f.datetime_select :date_and_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}, :order => [:day, :month, :year])
答案 1 :(得分:0)
发现问题出在控制器内部,仍然指的是我们现有的旧命名,因为所有更改似乎都在起作用