简体   繁体   中英

ruby on rails datetime select not updating db

im trying to use the builtin ruby helper for datetime select, though it doesnt seem to be passing the values through to 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])

console output

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

According to your label it's :date_and_time field in your database, right? If so you should use it in your datetime_select :

= f.datetime_select :date_and_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'}, :order => [:day, :month, :year])

发现问题出在控制器内,仍然指的是我们已有的旧命名,因为进行所有更改似乎都可行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM