我不知道还有什么地方可以解决这个问题:我花了很多时间在我的项目上,这是一个针对大学生的招聘活动网站,但已经达到了相当大的僵局。
简而言之,我在localhost中跋涉 - 添加像Devise这样的组件;通过提供商Facebook,LinkedIn和Google进行Omniauth身份验证 - 构建一个我为此感到自豪的网站。一切似乎都运转得很好,但是一旦我推到了“笨蛋大师”这里。事情开始打破大时间。
我认为问题最有可能出现在我们身边或周围:我有一个身份验证模型来跟踪单个用户的身份验证提供程序,以及用户 model(保留所有oauth代码的地方)。
不用多说,这是我的应用程序的heroku域名和我的代码:
http://lit-everglades-7633.herokuapp.com/
https://gist.github.com/mecampbellsoup/6357855
我怀疑的事情与之相关:
根据heroku日志(如下),与omniauth请求相关的路由和操作似乎正常工作,但实际上没有创建用户或身份验证:
在重置postgres db之后,我尝试运行' heroku run rake db:create'或者' db:setup'我抱怨如下:
☁duke_recruits[master] heroku run rake db:setup
运行rake db:setup
附加到终端... up,run.5886
致命:数据库" postgres"
详细信息:用户没有CONNECT权限。
☁duke_recruits[master] heroku run rake db:seed
运行rake db:seed
附加到终端...向上,运行1767年☁duke_recruits[master] heroku run rails c
运行rails c
附加到终端...向上,运行.6135
Event.allLoading生产环境(Rails 4.0.0)
IRB(主):001:0> Event.all
=> #ActiveRecord :: Relation [#Event id:1,title:nil,location:nil,description:nil,date:nil,end_date:nil,company_id:nil,created_at:" 2013-08-27 19:30 :06",updated_at:" 2013-08-27 19:30:06"]
IRB(主):002:0> Company.all
=> #ActiveRecord :: Relation [#Company id:1,name:nil,description:nil,website:nil,logo:nil,created_at:" 2013-08-27 19:30:06",updated_at: " 2013-08-27 19:30:06"]
日志(在heroku上打开应用并尝试使用Google身份验证时):
2013-08-27T19:49:18.701285 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:49:18 +0000的68.175.76.48 2013-08-27T19:49:18.701019 + 00:00 app [web.1]:=> Rails 4.0.0应用程序在http://0.0.0.0:49710上开始生产 2013-08-27T19:49:18.701019 + 00:00 app [web.1]:=> Ctrl-C关闭服务器
2013-08-27T19:49:18.701019 + 00:00 app [web.1]:=>启动WEBrick
2013-08-27T19:49:18.701019 + 00:00 app [web.1]:=>运行`rails server -h`以获取更多启动选项
2013-08-27T19:49:18.701019 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:49:18 +0000的68.175.76.48 2013-08-27T19:49:19.131115 + 00:00 heroku [router]:at = info method = GET path = / host = lit-everglades-7633.herokuapp.com fwd =" 68.175.76.48&#34 ; dyno = web.1 connect = 2ms service = 442ms status = 304 bytes = 0
2013-08-27T19:49:19.221284 + 00:00 heroku [router]:at = info method = GET path = / assets / application-b44a43097f814ac98347f6802323e25f.js host = lit-everglades-7633.herokuapp.com fwd =&#34 ; 68.175.76.48" dyno = web.1 connect = 1ms service = 12ms status = 304 bytes = 0
2013-08-27T19:49:49.440894 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:49:49 +0000的68.175.76.48 2013-08-27T19:49:49.440894 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:49:49 +0000的68.175.76.48 2013-08-27T19:49:49.515520 + 00:00 heroku [router]:at = info method = GET path = / host = lit-everglades-7633.herokuapp.com fwd =" 68.175.76.48&#34 ; dyno = web.1 connect = 2ms service = 80ms status = 304 bytes = 0
2013-08-27T19:50:48.534099 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:50:48 +0000的68.175.76.48 2013-08-27T19:50:48.534099 + 00:00 app [web.1]:开始GET" /"在2013-08-27 19:50:48 +0000的68.175.76.48 2013-08-27T19:50:48.575279 + 00:00 heroku [router]:at = info method = GET path = / host = lit-everglades-7633.herokuapp.com fwd =" 68.175.76.48&#34 ; dyno = web.1 connect = 1ms service = 51ms status = 304 bytes = 0
2013-08-27T19:50:52.293922 + 00:00 app [web.1]:开始GET" / users / sign_up"在2013-08-27 19:50:52 +0000的68.175.76.48 2013-08-27T19:50:52.293922 + 00:00 app [web.1]:开始GET" / users / sign_up"在2013-08-27 19:50:52 +0000的68.175.76.48 2013-08-27T19:50:52.591752 + 00:00 heroku [router]:at = info method = GET path = / users / sign_up host = lit-everglades-7633.herokuapp.com fwd =" 68.175.76.48 " dyno = web.1 connect = 1ms service = 307ms status = 304 bytes = 0
2013-08-27T19:51:00.368352 + 00:00 app [web.1]:开始GET" / users / auth / google_oauth2"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368352 + 00:00 app [web.1]:开始GET" / users / auth / google_oauth2"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368926 + 00:00 app [web.1]:I,[2013-08-27T19:51:00.368823#2] INFO - omniauth:(google_oauth2)请求阶段已启动。
2013-08-27T19:51:00.392262 + 00:00 heroku [router]:at = info method = GET path = / users / auth / google_oauth2 host = lit-everglades-7633.herokuapp.com fwd =" 68.175 .76.48" dyno = web.1 connect = 3ms service = 33ms status = 302 bytes = 469
2013-08-27T19:51:00.715597 + 00:00 app [web.1]:开始GET" / users / auth / google_oauth2"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.715597 + 00:00 app [web.1]:开始GET" / users / auth / google_oauth2"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.716822 + 00:00 app [web.1]:I,[2013-08-27T19:51:00.716706#2] INFO - omniauth:(google_oauth2)请求阶段已启动。
2013-08-27T19:51:00.997866 + 00:00 app [web.1]:已开始GET" / users / auth / google_oauth2 / callback?state = 40ecfd10739cb874b5c461fc00cfd72ec4fcb694ef3a6878& code = 4 / D_(ignored_for_security)_GBlmiYhY(partially_omitted )E9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.997866 + 00:00 app [web.1]:开始GET" / users / auth / google_oauth2 / callback?state = 10739cb874b5c461fc00cfd72ec4fcb694ef3a6878& code = 4 / D_GBlmiYhY1rCvgdgE9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI"对于68.175.76.48于2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.998508 + 00:00 app [web.1]:I,[2013-08-27T19:51:00.998379#2] INFO - omniauth:(google_oauth2)回调阶段已启动。
2013-08-27T19:51:02.188467 + 00:00 app [web.1]:开始GET" / users / sign_up"对于68.175.76.48在2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.188467 + 00:00 app [web.1]:开始GET" / users / sign_up"对于68.175.76.48在2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.234644 + 00:00 heroku [router]:at = info method = GET path = / users / sign_up host = lit-everglades-7633.herokuapp.com fwd =" 68.175.76.48 " dyno = web.1 connect = 9ms service = 52ms status = 304 bytes = 0
请让我知道您对我有什么问题,以及我是否可以澄清任何问题。我真的很感谢你的时间和帮助SO!
答案 0 :(得分:1)
在pg:reset之后,你可以运行create命令,但它通常会给你输出:
slkdjfs0dslkd already exists
那么你就会知道你的数据库已经创建并准备好使用了。在你可以种子之前,确保你迁移。只是标准的heroku方式
heroku run rake db:migrate
然后播种正常
heroku run rake db:seed