在Heroku上设置登录和注册自定义表单不行为

时间:2012-10-18 09:25:09

标签: heroku devise spree

所以在我的localhost上,自定义设计表单非常有用!没有任何问题 - 当我从另一个页面上的自定义表单登录时,它会将用户登录并按预期重定向到主页。

但是,当我部署到Heroku时,应用程序停止了行为 - 自定义表单将用户定向到实际登录页面而不登录。

这是我的Heroku Logs的输出:

2012-10-18T09:08:08+00:00 app[web.1]: Started POST "/user/sign_in" for 116.15.222.245 at 2012-10-18 09:08:08 +0000
2012-10-18T09:08:08+00:00 app[web.1]: cache: [POST /user/sign_in] invalidate, pass
2012-10-18T09:08:08+00:00 app[web.1]:   Processing by UserSessionsController#create as HTML
2012-10-18T09:08:08+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"4WDTRkX842UVz7nFuGbWbA3z47+rraKXQgl3PRYuWJY=", "user"=>{"email"=>"spree@example.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log In"}
2012-10-18T09:08:08+00:00 app[web.1]: Redirected to https://example.com/user/sign_in
2012-10-18T09:08:08+00:00 app[web.1]: Completed 302 Found in 11ms
2012-10-18T09:08:08+00:00 heroku[router]: POST example.com/user/sign_in dyno=web.1 queue=0 wait=0ms service=16ms status=302 bytes=101
2012-10-18T09:08:08+00:00 heroku[nginx]: 108.162.225.233 - - [18/Oct/2012:09:08:08 +0000] "POST /user/sign_in HTTP/1.1" 302 101 "http://example.com/referral_login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1" example.com
2012-10-18T09:08:10+00:00 app[web.1]: 
2012-10-18T09:08:10+00:00 app[web.1]: Started GET "/user/sign_in" for 116.15.222.245 at 2012-10-18 09:08:10 +0000
2012-10-18T09:08:10+00:00 app[web.1]: 
2012-10-18T09:08:10+00:00 heroku[router]: GET example.com/user/sign_in dyno=web.1 queue=0 wait=0ms service=16ms status=200 bytes=7835
2012-10-18T09:08:10+00:00 app[web.1]: cache: [GET /user/sign_in] miss
2012-10-18T09:08:10+00:00 app[web.1]:   Processing by UserSessionsController#new as HTML
2012-10-18T09:08:10+00:00 app[web.1]: Rendered shared/_error_messages.html.erb (0.1ms)
2012-10-18T09:08:10+00:00 app[web.1]: Rendered shared/_login.html.erb (2.3ms)
2012-10-18T09:08:10+00:00 app[web.1]: Rendered user_sessions/new.html.erb within layouts/spree_application (3.0ms)
2012-10-18T09:08:10+00:00 app[web.1]: Rendered shared/_head.html.erb (1.0ms)
2012-10-18T09:08:10+00:00 app[web.1]: Rendered shared/_store_menu.html.erb (0.7ms)
2012-10-18T09:08:10+00:00 app[web.1]: Rendered shared/_top_menu_bar.html.erb (0.5ms)
2012-10-18T09:08:10+00:00 heroku[nginx]: 108.162.225.233 - - [18/Oct/2012:09:08:10 +0000] "GET /user/sign_in HTTP/1.1" 200 3412 "http://example.com/referral_login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1" example.com

这是我在localhost上的输出:

Started POST "/user/sign_in" for 127.0.0.1 at 2012-10-18 17:21:36 +0800
  Processing by UserSessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"m38Y47hk4UyGYAMnd76y5Qo2nK1Nv//v7s2+XdNHCbU=", "user"=>{"email"=>"spree@example.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log In"}
  User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'spree@example.com' LIMIT 1
   (23.6ms)  SELECT COUNT(DISTINCT "users"."id") FROM "users" LEFT OUTER JOIN "roles_users" ON "roles_users"."user_id" = "users"."id" LEFT OUTER JOIN "roles" ON "roles"."id" = "roles_users"."role_id" WHERE "roles"."name" = 'admin'
   (0.5ms)  UPDATE "users" SET "last_sign_in_at" = '2012-10-18 05:56:54.897695', "current_sign_in_at" = '2012-10-18 09:21:39.033308', "sign_in_count" = 75, "updated_at" = '2012-10-18 09:21:39.081684' WHERE "users"."id" = 1
Redirected to http://localhost:3000/
Completed 302 Found in 227ms

Started GET "/" for 127.0.0.1 at 2012-10-18 17:21:39 +0800
  Processing by LandingController#index as HTML
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered landing/index.html.erb within layouts/spree_application (1.7ms)
Rendered shared/_head.html.erb (2.0ms)
Rendered shared/_store_menu.html.erb (2.6ms)
Rendered shared/_top_menu_bar.html.erb (1.7ms)
  Tracker Load (0.3ms)  SELECT "trackers".* FROM "trackers" WHERE "trackers"."active" = 't' AND "trackers"."environment" = 'development' LIMIT 1
Rendered shared/_google_analytics.html.erb (14.1ms)
Completed 200 OK in 183ms (Views: 148.1ms | ActiveRecord: 1.9ms)

任何人都可以帮助解释为什么会这样,以及如何解决这个问题?我查看了Devise wiki,做了一堆Google搜索并尝试了一些没有成功的事情。非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

Spree默认在生产环境中要求SSL,因此如果您的POST请求不是https,它将重定向到登录页面。