Hi everyone, I''m working through the tutorial at the following link and attempting to customise/adapt the lessons for my own slightly different application. Link: Ruby on Rails Tutorial: Learn Rails by Example | Ruby on Rails 3 Tutorial book and screencasts | by Michael Hartl <http://ruby.railstutorial.org/ruby-on-rails-tutorial-book> I''m currently trying to work through chapter 10, but having some problems with the variable ''current_user'' not being properly defined in the ''signed_in'' method. Everything looks fine to me, but as I am obviously missing something I''d appreciate it if someone with more experience at debugging could point me in the right direction. I can sign in with my test users and the exception only occures when attempting to edit a profile. Controller and model are attached. Cheers, Jen. Error: NameError in UsersController#edit undefined local variable or method `current_user'' for #<UsersController:0x9ffad80> |Rails.root: /home/resource_portal/website| Application Trace <http://localhost:3000/users/1/edit#> | Framework Trace <http://localhost:3000/users/1/edit#> | Full Trace <http://localhost:3000/users/1/edit#> |app/helpers/sessions_helper.rb:17:in `signed_in?'' app/controllers/users_controller.rb:91:in `authenticate'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:436:in `_run__1056153724__process_action__372525482__callbacks'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:in `run_callbacks'' rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:17:in `process_action'' rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in `block in instrument'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'' rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in `instrument'' rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:29:in `process_action'' rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/rescue.rb:17:in `process_action''| ... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The error message is pretty clear - You haven''t defined a current_usermethod in your helper. Check out Listing 9.16 in that tutorial you posted. That''s where it describes the current_user method you need to add. http://ruby.railstutorial.org/chapters/sign-in-sign-out#code:current_user_working -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/1sGjKBBYzikJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you including SessionsHelper in you ApplicationController ? class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper end Simon On Jun 12, 3:43 pm, Jen <jen.bot...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi everyone, > I''m working through the tutorial at the following link and attempting to > customise/adapt the lessons for my own slightly different application. > > Link: > Ruby on Rails Tutorial: Learn Rails by Example | Ruby on Rails 3 > Tutorial book and screencasts | by Michael Hartl > <http://ruby.railstutorial.org/ruby-on-rails-tutorial-book> > > I''m currently trying to work through chapter 10, but having some > problems with the variable ''current_user'' not being properly defined in > the ''signed_in'' method. Everything looks fine to me, but as I am > obviously missing something I''d appreciate it if someone with more > experience at debugging could point me in the right direction. > > I can sign in with my test users and the exception only occures when > attempting to edit a profile. > > Controller and model are attached. > Cheers, > Jen. > > Error: > > NameError in UsersController#edit > > undefined local variable or method `current_user'' for #<UsersController:0x9ffad80> > > |Rails.root: /home/resource_portal/website| > > Application Trace <http://localhost:3000/users/1/edit#> | Framework > Trace <http://localhost:3000/users/1/edit#> | Full Trace > <http://localhost:3000/users/1/edit#> > > |app/helpers/sessions_helper.rb:17:in `signed_in?'' > app/controllers/users_controller.rb:91:in `authenticate'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:436:in `_run__1056153724__process_action__372525482__callbacks'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:409:in `_run_process_action_callbacks'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:93:in `run_callbacks'' > rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/abstract_controller/callbac ks.rb:17:in `process_action'' > rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/ins trumentation.rb:30:in `block in process_action'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions.rb:52:in `block in instrument'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions/instrumenter.rb:21:in `instrument'' > rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions.rb:52:in `instrument'' > rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/ins trumentation.rb:29:in `process_action'' > rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/res cue.rb:17:in `process_action''| > ... > > users_controller.rb > 2KViewDownload > > sessions_helper.rb > 1KViewDownload-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi, Moved the authenticate method to the helper, after looking at the sample app code from github. This seems to have solved the problem. Thanks, Jen. On 13/06/11 14:49, Simon Baumgartner wrote:> Are you including SessionsHelper in you ApplicationController ? > > class ApplicationController< ActionController::Base > protect_from_forgery > include SessionsHelper > end > > Simon > > On Jun 12, 3:43 pm, Jen<jen.bot...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi everyone, >> I''m working through the tutorial at the following link and attempting to >> customise/adapt the lessons for my own slightly different application. >> >> Link: >> Ruby on Rails Tutorial: Learn Rails by Example | Ruby on Rails 3 >> Tutorial book and screencasts | by Michael Hartl >> <http://ruby.railstutorial.org/ruby-on-rails-tutorial-book> >> >> I''m currently trying to work through chapter 10, but having some >> problems with the variable ''current_user'' not being properly defined in >> the ''signed_in'' method. Everything looks fine to me, but as I am >> obviously missing something I''d appreciate it if someone with more >> experience at debugging could point me in the right direction. >> >> I can sign in with my test users and the exception only occures when >> attempting to edit a profile. >> >> Controller and model are attached. >> Cheers, >> Jen. >> >> Error: >> >> NameError in UsersController#edit >> >> undefined local variable or method `current_user'' for #<UsersController:0x9ffad80> >> >> |Rails.root: /home/resource_portal/website| >> >> Application Trace<http://localhost:3000/users/1/edit#> | Framework >> Trace<http://localhost:3000/users/1/edit#> | Full Trace >> <http://localhost:3000/users/1/edit#> >> >> |app/helpers/sessions_helper.rb:17:in `signed_in?'' >> app/controllers/users_controller.rb:91:in `authenticate'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:436:in `_run__1056153724__process_action__372525482__callbacks'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:409:in `_run_process_action_callbacks'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/callbacks .rb:93:in `run_callbacks'' >> rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/abstract_controller/callbac ks.rb:17:in `process_action'' >> rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/ins trumentation.rb:30:in `block in process_action'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions.rb:52:in `block in instrument'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions/instrumenter.rb:21:in `instrument'' >> rake-0.8.7/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/notificat ions.rb:52:in `instrument'' >> rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/ins trumentation.rb:29:in `process_action'' >> rake-0.8.7/ruby/1.9.1/gems/actionpack-3.0.3/lib/action_controller/metal/res cue.rb:17:in `process_action''| >> ... >> >> users_controller.rb >> 2KViewDownload >> >> sessions_helper.rb >> 1KViewDownload-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Apparently Analagous Threads
- Action Controller Error: undefined local variable or method `current_user'
- Rails 4.0 has_many_through and fields_for
- before_save messing up
- Rails 3 Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
- Rails 3 Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)