Rails 3.2.13、postgres、ruby 1.9.3 アプリを使用していますが、オブジェクトが一時的に保存されているように見えてから消えるという問題が発生しています。
Railsコンソールで、次のことを行いました。
s = Shop.create( name: "my shop", city:"NY", state: "NY", user_id: 2)
(0.4ms) BEGIN
SQL (1.0ms) INSERT INTO "shops" ("about", "address1", "address2", "city", "created_at", "image", "name", "state", "stripe_shop_token", "updated_at", "user_id", "zip") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING "id" [["about", nil], ["address1", nil], ["address2", nil], ["city", "NY"], ["created_at", Tue, 09 Jul 2013 18:39:40 UTC +00:00], ["image", nil], ["name", "my shop"], ["state", "NY"], ["stripe_shop_token", nil], ["updated_at", Tue, 09 Jul 2013 18:39:40 UTC +00:00], ["user_id", 2], ["zip", nil]]
(0.6ms) COMMIT
=> #<Shop id: 46, user_id: 2, name: "my shop", address1: nil, address2: nil, city: "NY", state: "NY", zip: nil, about: nil, image: nil, stripe_shop_token: nil, created_at: "2013-07-09 18:39:40", updated_at: "2013-07-09 18:39:40">
Shop.all
Shop Load (1.0ms) SELECT "shops".* FROM "shops"
=> [#<Shop id: 46, user_id: 2, name: "my shop", address1: nil, address2: nil, city: "NY", state: "NY", zip: nil, about: nil, image: nil, stripe_shop_token: nil, created_at: "2013-07-09 18:39:40", updated_at: "2013-07-09 18:39:40">]
ショップがコンソールに保存されているように見えます。コンピューターをシャットダウンした後、コンソールでショップを元に戻すことができました。アプリを再起動すると、ショップはまだ認識されているように見えますが、アプリケーションで何かを行うと、ショップが見つからなくなります。直接ショップ ビューに移動すると、ページを切り替えるまでショップが表示され、その後、ショップが見つかりません。
サーバーログファイルの一部を次に示します。
15:00:12 web.1 | Started POST "/__better_errors/2165427460/variables" for 127.0.0.1 at 2013-07-09 14:51:59 -0400
15:00:12 web.1 | Started GET "/" for 127.0.0.1 at 2013-07-09 14:57:45 -0400
15:00:12 web.1 | Processing by HomeController#index as HTML
15:00:12 web.1 | Rendered home/index.html.erb within layouts/application (1.5ms)
15:00:12 web.1 | User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'ZN0O_btNVpCoktAOBlM3OQ' LIMIT 1
15:00:12 web.1 | Shop Load (0.5ms) SELECT "shops".* FROM "shops" WHERE "shops"."user_id" = 2 LIMIT 1
15:00:12 web.1 | Rendered layouts/_header.html.erb (5.7ms)
15:00:12 web.1 | Rendered layouts/_error.html.erb (0.1ms)
15:00:12 web.1 | Rendered layouts/_footer.html.erb (0.6ms)
15:00:12 web.1 | Processing by HomeController#index as HTML
15:00:12 web.1 | Rendered home/index.html.erb within layouts/application (1.2ms)
15:00:12 web.1 | User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'ZN0O_btNVpCoktAOBlM3OQ' LIMIT 1
15:00:12 web.1 | Shop Load (0.9ms) SELECT "shops".* FROM "shops" WHERE "shops"."user_id" = 2 LIMIT 1
15:00:12 web.1 | Rendered layouts/_header.html.erb (6.7ms)
15:00:12 web.1 | Rendered layouts/_error.html.erb (0.1ms)
15:00:12 web.1 | (0.2ms) BEGIN
15:00:12 web.1 | CartOrder Load (0.4ms) SELECT "cart_orders".* FROM "cart_orders" WHERE "cart_orders"."shop_id" = 49
15:00:12 web.1 | Item Load (0.4ms) SELECT "items".* FROM "items" WHERE "items"."shop_id" = 49
15:00:12 web.1 | SQL (0.4ms) DELETE FROM "shops" WHERE "shops"."id" = $1 [["id", 49]]
15:00:12 web.1 | (0.6ms) COMMIT
15:00:12 web.1 | Rendered layouts/_footer.html.erb (7.6ms)
15:00:12 web.1 | Completed 200 OK in 86ms (Views: 82.0ms | ActiveRecord: 3.6ms)
どの情報が役立つかさえわからないほど行き詰まっています。
ありがとうスティーブ