Ruby on rails application works locally, but does not work on geroku

I am doing a michael hartl tutorial for rubies on rails and everything works fine locally, but not on the hero when the application is deployed .. this problem occurs before chapter 7 of this book: http://ruby.railstutorial.org/ruby-on-rails -tutorial-book # top

Are there any details needed to debug this issue? please let me know.....

here are the hero's magazines:

$ 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]: 
+7
source share
8 answers

So I also did the Hart tutorial and went into the EXACT problem. I started launching heroku db: migrate .... I made sure it was updated with git push heroku .... I added memory_key to my one user in the database. This was in the schema.rb file.

I finally found the answer:

user.rb:

add: remember_token to attr_accessible

Example: "attr_accessible: name ,: email ,: password ,: password_confirmation ,: remember_token"

For some reason this is excluded from the textbook, although now that I know what is wrong, it makes sense. Having added this, I again clicked on the little healer and Viola ....

Hope this helps :)

+9
source

Dynamic crawlers work only if the attribute you are looking for exists. Either you did not run all the migrations, or you simply did not have this attribute (remember_token), or you wrote it incorrectly.

+3
source

I had the same problem and I have to say that IMHO does not need to be added :remember_token in the attr_accessible field. By doing this, you open :remember_token , creating getters and setters, which is optional, since :remember_token should be considered as an internal variable. I solved the Heroku application restart problem, confirmed here:

heroku-nomethod-error-remember-token

After rebooting, the application worked correctly, as it ran locally.

+3
source

It fails because it does not find the definition of the next find_by_remember_token method. I remember that remember_token is defined in session_helper in the Hartl tutorial. It seems to signed_in? when the signed_in? method is signed_in? .

Could you insert the model code for session_helper.rb and User ?

+1
source

Try running heroku restart . He helped.

It should be noted that adding :remembered_token to your attr_accessible ad attr_accessible not recommended, according to r4m's answer . (There's a reason Hartle didn't do this in the textbook.)

+1
source

Line:

 ActionView::Template::Error (undefined method `find_by_remember_token' for #<Class:0x00000004960740>): 

tells you that Rails does not know what "find_by_remember_token" is, which means that it either does not exist (that is, a typo), or the database, which is usually used to determine the properties of a class, t knows about this field.

Assuming this is not a typo, the database migration will be as follows:

 heroku run rake db:migrate 
0
source

I was getting an internal server error when I tried to click on a hero as well as on Amazon. I had to pre-assemble my assets before pushing the application to the server. If this is your problem, the easiest solution was to run

 RAILS_ENV=production rake assets:precompile 

or add upload 'deploy / assets' to the capfile if you use Capistrano. I was told that you can add the following to the deploy.rb file, but I could not get it to work.

 after "deploy:restart", "deploy:precompile" namespace :deploy do desc "Compile assets" task :precompile, :roles => :app do run "cd #{release_path} && rake RAILS_ENV=#{rails_env} assets:precompile" end end 
0
source

What worked for me was the definition of the create_remember_token method in the User model, as described in the tutorial.

 private def create_remember_token self.remember_token = SecureRandom.urlsafe_base64 end 

And then call it in the before_save method.

 before_save { self.email.downcase! create_remember_token } 

I did not have it as a method declaration before. And while he was working on my computer, he failed at Heroku.

 #this failed in Heroku before_save { self.email.downcase! self.remember_token = SecureRandom.urlsafe_base64 } 

In addition, there will be no harm to start:

 heroku run rake db:migrate 
0
source

All Articles