gpt4 book ai didi

ruby-on-rails - Ruby on Rails应用程序可在本地工作,但在heroku上不工作

转载 作者:行者123 更新时间:2023-12-04 05:19:38 24 4
gpt4 key购买 nike

我正在为迈克尔·哈特尔(Michael Hartl)做的关于Rails上的 ruby 的教程,当应用程序部署时,一切在本地都可以正常运行,但是在heroku上却不能。

您需要调试此问题的任何详细信息吗?请告诉我.....

以下是heroku日志:

$ 2012-07-18T06:10:26+00:00 app[web.1]:     6:         <ul class="nav pull-right">

2012-07-18T06:10:26+00:00 app[web.1]: ActionView::Template::Error (undefined met
hod `find_by_remember_token' for #<Class:0x00000004960740>):
2012-07-18T06:10:26+00:00 app[web.1]: 7: <li><%= link_to "Home", r
oot_path %></li>
2012-07-18T06:10:26+00:00 app[web.1]: 8: <li><%= link_to "Help", h
elp_path %></li>
2012-07-18T06:10:26+00:00 app[web.1]: 9: <% if signed_in? %>
2012-07-18T06:10:26+00:00 app[web.1]: 10: <li><%= link_to "Users
", users_path %></li>
2012-07-18T06:10:26+00:00 app[web.1]: 11: <li id="fat-menu" clas
s="dropdown">
2012-07-18T06:10:26+00:00 app[web.1]: 12: <a href="#" class="d
ropdown-toggle" data-toggle="dropdown">
2012-07-18T06:10:26+00:00 app[web.1]: app/helpers/sessions_helper.rb:10:in `cu
rrent_user'
2012-07-18T06:10:26+00:00 app[web.1]: app/helpers/sessions_helper.rb:23:in `si
gned_in?'
2012-07-18T06:10:26+00:00 app[web.1]: app/views/layouts/application.html.erb:1
1:in `_app_views_layouts_application_html_erb___2533055855927805914_43132200'
2012-07-18T06:10:26+00:00 app[web.1]: app/views/layouts/_header.html.erb:9:in
`_app_views_layouts__header_html_erb__2547305690965663969_41244280'
2012-07-18T06:10:26+00:00 app[web.1]:
2012-07-18T06:10:26+00:00 app[web.1]:
2012-07-18T06:10:26+00:00 heroku[router]: GET whizcollab.herokuapp.com/ dyno=web
.1 queue=0 wait=0ms service=345ms status=500 bytes=643
2012-07-18T06:10:34+00:00 app[web.1]:
2012-07-18T06:10:34+00:00 app[web.1]: Started GET "/" for 115.87.214.246 at 2012
-07-18 06:10:34 +0000
2012-07-18T06:10:34+00:00 app[web.1]:
2012-07-18T06:10:34+00:00 app[web.1]: Processing by StaticPagesController#home a
s HTML
2012-07-18T06:10:34+00:00 app[web.1]: Rendered static_pages/home.html.erb with
in layouts/application (0.6ms)
2012-07-18T06:10:34+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2012-07-18T06:10:34+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.2ms
)
2012-07-18T06:10:34+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms

2012-07-18T06:10:34+00:00 app[web.1]: ActionView::Template::Error (undefined met
hod `find_by_remember_token' for #<Class:0x00000004960740>):
2012-07-18T06:10:34+00:00 app[web.1]:
2012-07-18T06:10:34+00:00 app[web.1]: 8: <li><%= link_to "Help", h
elp_path %></li>
2012-07-18T06:10:34+00:00 app[web.1]: 9: <% if signed_in? %>
2012-07-18T06:10:34+00:00 app[web.1]: 6: <ul class="nav pull-right">

2012-07-18T06:10:34+00:00 app[web.1]: 10: <li><%= link_to "Users
", users_path %></li>
2012-07-18T06:10:34+00:00 app[web.1]: 7: <li><%= link_to "Home", r
oot_path %></li>
2012-07-18T06:10:34+00:00 app[web.1]: 11: <li id="fat-menu" clas
s="dropdown">
2012-07-18T06:10:34+00:00 app[web.1]: 12: <a href="#" class="d
ropdown-toggle" data-toggle="dropdown">
2012-07-18T06:10:34+00:00 app[web.1]: app/helpers/sessions_helper.rb:10:in `cu
rrent_user'
2012-07-18T06:10:34+00:00 app[web.1]: app/views/layouts/_header.html.erb:9:in
`_app_views_layouts__header_html_erb__2547305690965663969_41244280'
2012-07-18T06:10:34+00:00 app[web.1]: app/helpers/sessions_helper.rb:23:in `si
gned_in?'
2012-07-18T06:10:34+00:00 app[web.1]: app/views/layouts/application.html.erb:1
1:in `_app_views_layouts_application_html_erb___2533055855927805914_43132200'
2012-07-18T06:10:34+00:00 app[web.1]:
2012-07-18T06:10:34+00:00 app[web.1]:
2012-07-18T06:10:34+00:00 heroku[router]: GET whizcollab.herokuapp.com/ dyno=web
.1 queue=0 wait=0ms service=22ms status=500 bytes=643
2012-07-18T06:12:03+00:00 app[web.1]:
2012-07-18T06:12:03+00:00 app[web.1]:
2012-07-18T06:12:03+00:00 app[web.1]: Started GET "/" for 115.87.214.246 at 2012
-07-18 06:12:03 +0000
2012-07-18T06:12:03+00:00 app[web.1]: Processing by StaticPagesController#home a
s HTML
2012-07-18T06:12:03+00:00 app[web.1]: Rendered static_pages/home.html.erb with
in layouts/application (0.7ms)
2012-07-18T06:12:03+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2012-07-18T06:12:03+00:00 app[web.1]: Completed 500 Internal Server Error in 6ms

2012-07-18T06:12:03+00:00 app[web.1]: Rendered layouts/_header.html.erb (2.3ms
)
2012-07-18T06:12:03+00:00 app[web.1]: ActionView::Template::Error (undefined met
hod `find_by_remember_token' for #<Class:0x00000004960740>):
2012-07-18T06:12:03+00:00 app[web.1]:
2012-07-18T06:12:03+00:00 app[web.1]: 6: <ul class="nav pull-right">

2012-07-18T06:12:03+00:00 app[web.1]: 7: <li><%= link_to "Home", r
oot_path %></li>
2012-07-18T06:12:03+00:00 app[web.1]: 8: <li><%= link_to "Help", h
elp_path %></li>
2012-07-18T06:12:03+00:00 app[web.1]: 9: <% if signed_in? %>
2012-07-18T06:12:03+00:00 app[web.1]: 11: <li id="fat-menu" clas
s="dropdown">
2012-07-18T06:12:03+00:00 app[web.1]: 10: <li><%= link_to "Users
", users_path %></li>
2012-07-18T06:12:03+00:00 app[web.1]: 12: <a href="#" class="d
ropdown-toggle" data-toggle="dropdown">
2012-07-18T06:12:03+00:00 app[web.1]: app/helpers/sessions_helper.rb:10:in `cu
rrent_user'
2012-07-18T06:12:03+00:00 app[web.1]: app/helpers/sessions_helper.rb:23:in `si
gned_in?'
2012-07-18T06:12:03+00:00 app[web.1]: app/views/layouts/_header.html.erb:9:in
`_app_views_layouts__header_html_erb__2547305690965663969_41244280'
2012-07-18T06:12:03+00:00 app[web.1]: app/views/layouts/application.html.erb:1
1:in `_app_views_layouts_application_html_erb___2533055855927805914_43132200'
2012-07-18T06:12:03+00:00 app[web.1]:
2012-07-18T06:12:03+00:00 app[web.1]:
2012-07-18T06:12:03+00:00 heroku[router]: GET whizcollab.herokuapp.com/ dyno=web
.1 queue=0 wait=0ms service=17ms status=500 bytes=643
2012-07-18T06:13:31+00:00 app[web.1]:
2012-07-18T06:13:31+00:00 app[web.1]:
2012-07-18T06:13:31+00:00 app[web.1]: Started GET "/" for 115.87.214.246 at 2012
-07-18 06:13:31 +0000
2012-07-18T06:13:31+00:00 app[web.1]: Processing by StaticPagesController#home a
s HTML
2012-07-18T06:13:31+00:00 app[web.1]: Rendered static_pages/home.html.erb with
in layouts/application (0.4ms)
2012-07-18T06:13:31+00:00 app[web.1]: Rendered layouts/_shim.html.erb (0.0ms)
2012-07-18T06:13:31+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.9ms
)
2012-07-18T06:13:31+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms

2012-07-18T06:13:31+00:00 app[web.1]:
2012-07-18T06:13:31+00:00 app[web.1]: ActionView::Template::Error (undefined met
hod `find_by_remember_token' for #<Class:0x00000004960740>):
2012-07-18T06:13:31+00:00 app[web.1]: 6: <ul class="nav pull-right">

2012-07-18T06:13:31+00:00 app[web.1]: 7: <li><%= link_to "Home", r
oot_path %></li>
2012-07-18T06:13:31+00:00 app[web.1]: 9: <% if signed_in? %>
2012-07-18T06:13:31+00:00 app[web.1]: 11: <li id="fat-menu" clas
s="dropdown">
2012-07-18T06:13:31+00:00 app[web.1]: 10: <li><%= link_to "Users
", users_path %></li>
2012-07-18T06:13:31+00:00 app[web.1]: 8: <li><%= link_to "Help", h
elp_path %></li>
2012-07-18T06:13:31+00:00 app[web.1]: 12: <a href="#" class="d
ropdown-toggle" data-toggle="dropdown">
2012-07-18T06:13:31+00:00 app[web.1]: app/helpers/sessions_helper.rb:10:in `cu
rrent_user'
2012-07-18T06:13:31+00:00 app[web.1]: app/helpers/sessions_helper.rb:23:in `si
gned_in?'
2012-07-18T06:13:31+00:00 app[web.1]: app/views/layouts/application.html.erb:1
1:in `_app_views_layouts_application_html_erb___2533055855927805914_43132200'
2012-07-18T06:13:31+00:00 app[web.1]:
2012-07-18T06:13:31+00:00 app[web.1]: app/views/layouts/_header.html.erb:9:in
`_app_views_layouts__header_html_erb__2547305690965663969_41244280'
2012-07-18T06:13:31+00:00 app[web.1]:
2012-07-18T06:13:31+00:00 heroku[router]: GET whizcollab.herokuapp.com/ dyno=web
.1 queue=0 wait=0ms service=22ms status=500 bytes=643
2012-07-18T06:13:37+00:00 app[web.1]:
2012-07-18T06:13:37+00:00 app[web.1]:
2012-07-18T06:13:37+00:00 app[web.1]: Started GET "/users" for 115.87.214.246 at
2012-07-18 06:13:37 +0000
2012-07-18T06:13:37+00:00 heroku[router]: GET whizcollab.herokuapp.com/users dyn
o=web.1 queue=0 wait=0ms service=47ms status=500 bytes=643
2012-07-18T06:13:37+00:00 app[web.1]: Processing by UsersController#index as HTM
L
2012-07-18T06:13:37+00:00 app[web.1]: Completed 500 Internal Server Error in 1ms

2012-07-18T06:13:37+00:00 app[web.1]:
2012-07-18T06:13:37+00:00 app[web.1]: app/helpers/sessions_helper.rb:10:in `cu
rrent_user'
2012-07-18T06:13:37+00:00 app[web.1]: NoMethodError (undefined method `find_by_r
emember_token' for #<Class:0x00000004960740>):
2012-07-18T06:13:37+00:00 app[web.1]: app/helpers/sessions_helper.rb:23:in `si
gned_in?'
2012-07-18T06:13:37+00:00 app[web.1]: app/controllers/users_controller.rb:48:i
n `signed_in_user'
2012-07-18T06:13:37+00:00 app[web.1]:
2012-07-18T06:13:37+00:00 app[web.1]:

最佳答案

因此,我也在做《 Hart教程》,并且遇到了SAME问题。我运行了heroku运行db:migrate ....我确保它是最新的git push heroku ....它在schema.rb文件中。

我终于找到了答案:

user.rb:

将:remember_token添加到attr_accessible

例如:“attr_accessible:name,:email,:password,:password_confirmation,:remember_token”

出于某种原因,尽管现在我知道发生了什么错误,但仍将其排除在本教程之外。添加此内容后,我将其重新推送到heroku和Viola。

希望这可以帮助 :)

关于ruby-on-rails - Ruby on Rails应用程序可在本地工作,但在heroku上不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11534902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com