我正在做michael hartl关于
ruby on rails的教程,一切都在本地工作正常但在应用程序部署时不在heroku上.这个问题出现在本书第7章之前:
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#top
你需要调试这个问题的细节吗?请告诉我…..
这是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教程并且正在进入相同的问题.我运行了heroku运行db:migrate ….我确保它是最新的git push heroku ….我在数据库中为我的一个用户添加了一个remember_key.它位于schema.rb文件中.
我终于找到了答案:
user.rb:
add:remember_token to attr_accessible
例如:“attr_accessible:name,:email,:password,:password_confirmation,:remember_token”
出于某种原因,这是在教程之外,即使现在我知道什么是错的,这是有道理的.添加这个后我重新推到了heroku和Viola ….
希望这可以帮助 :)