I've been faithfully been following along with Rails Tutorial 3 and been loving it but am totally stuck with where I've gone wrong after section 9.3.3. Signin Success -> Current user.
I run the rspec tests rspec/spec but have one failure in my sessions_helper.
For some reason the controller.current_user doesn't == @user and I can't for the life of me figure out where I went wrong or why this doesn't work. I understand where things got to for it to fail but can't work out why.
What's more frustrating to me as I'm starting out with rails is I don't know where to even start trying to debug this or what the debugging process is.
I would be eternally grateful if anyone wanted to take on the challenge of forking this from my github [https://github.com/markstewie/railstut_sampleapp][1] and trying to work out the problem. I would be even more grateful if any开发者_Python百科one could explain the process you would go through to debug a problem like this... I'm seriously stumped.
/////////////////// SOLUTION /////////////////////////
Sorry guys, I've just found the problem!!! At last...
in session_helper I had.
def remember_token
cookies.signed(:remember_token) || [nil,nil]
rather than
def remember_token
cookies.signed[:remember_token] || [nil,nil]
This has been by far the hardest section to understand and I still don't fully but at least it's working now.
Thanks for your time! Mark.
Just been struggling with the same section, here's what I found:
Make sure that in sessions_helper.rb you have both the current_user=(user)
method from listing 9.15 and the improved current_user
method from listing 9.16
and
I had to modify the signed_in?
method in session_helper.rb like this:
def signed_in?
!self.current_user.nil?
end
There is actually a remark about changing current_user
to self.current_user
in footnote 9.6, though that seems to be related to some other section.
HTH
Cloned your rep, run bundle install, migrated the database und run rake rspec. All your tests pass. Can you show your output?
Edit: This was the output
77:test2 markus$ rake spec
(in /Users/markus/Dropbox/Rails/test2)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S bundle exec rspec ./spec/controllers/pages_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/models/user_spec.rb ./spec/requests/layout_links_spec.rb ./spec/requests/users_spec.rb
No DRb server is running. Running in local process instead ...
...................................................
Finished in 3.81 seconds
51 examples, 0 failures
精彩评论