简体   繁体   中英

Rails record update works locally but not in production

Any reason why a simple update would work locally but not in production on heroku (the repos are identical, everything up to date)? In the logs below I can see the parameter to be updated is making it into the request, but somehow the sql output only updates updated at:

Video Update (3.1ms)  UPDATE "videos" SET "updated_at" = $1 WHERE "videos"."id" = $2  [["updated_at", "2018-01-07 20:54:51.465131"], ["id", 85]]

In Development the exact same code produces in the dev server logs:

Video Update (0.7ms)  UPDATE "videos" SET "imdb_id" = $1, "updated_at" = $2 WHERE "videos"."id" = $3  [["imdb_id", "566"], ["updated_at", "2018-01-07 20:09:28.366552"], ["id", 119]]

So an update is being made but without the parameter, even though the param is whitelisted and included in the request log. I'm not even sure what information to include with this question or where the problem is (rails, postgres, heroku).

My production log:

2018-01-07T20:54:51.408709+00:00 app[web.1]: I, [2018-01-07T20:54:51.408622 #4]  INFO -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1] Processing by VideosController#update as HTML

2018-01-07T20:54:51.408843+00:00 app[web.1]: I, [2018-01-07T20:54:51.408752 #4]  INFO -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"NJR5RNVHisPn1rDbglvmEIE80fk3pZjEfZ0YqOpXKGldRLR2JitrJrGf/syXfMaO8AiMtvo7N/EJqM/ToLkSLQ==", "file"=>"", "video"=>{"title"=>"Coco", "description"=>"", "imdb_id"=>"777", "public"=>"true"}, "commit"=>"Update", "id"=>"85"}

2018-01-07T20:54:51.445716+00:00 app[web.1]: D, [2018-01-07T20:54:51.445569 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]   Video Load (7.6ms)  SELECT  "videos".* FROM "videos" WHERE "videos"."id" = $1 LIMIT $2  [["id", 85], ["LIMIT", 1]]

2018-01-07T20:54:51.448739+00:00 app[web.1]: D, [2018-01-07T20:54:51.448624 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]   User Load (1.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 7], ["LIMIT", 1]]

2018-01-07T20:54:51.451649+00:00 app[web.1]: D, [2018-01-07T20:54:51.451565 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]    (0.9ms)  BEGIN

2018-01-07T20:54:51.459864+00:00 app[web.1]: D, [2018-01-07T20:54:51.459743 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]   User Load (5.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 7], ["LIMIT", 1]]

2018-01-07T20:54:51.485827+00:00 app[web.1]: D, [2018-01-07T20:54:51.485674 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]   Video Update (3.1ms)  UPDATE "videos" SET "updated_at" = $1 WHERE "videos"."id" = $2  [["updated_at", "2018-01-07 20:54:51.465131"], ["id", 85]]

2018-01-07T20:54:51.490476+00:00 app[web.1]: D, [2018-01-07T20:54:51.490385 #4] DEBUG -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1]    (2.4ms)  COMMIT

2018-01-07T20:54:51.491713+00:00 app[web.1]: I, [2018-01-07T20:54:51.491568 #4]  INFO -- : [6fad6a5f-021f-46ec-93a8-de53735f66f1] Redirected to https://www.browzable.com/library

It worked after I restarted Heroku. Maybe it didn't restart after my migration.

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