Rails Hartl Tutorial: Unable to Fix NoMethodError in PasswordResetsTest - ruby-on-rails

I am getting the following NoMethodError even though my database table has the reset_sent_at column and User.last.reset_sent_at is not nil.
I will appreciate if anyone can help in fixing this error. Thanks.
PasswordResetsTest#test_password_resets:
NoMethodError: undefined method `reset_sent_at=' for #<User:0x00007f8e34164210>
Did you mean? reset_token=
app/models/user.rb:66:in `create_reset_digest'
app/controllers/password_resets_controller.rb:14:in `create'
test/integration/password_resets_test.rb:19:in `block in <class:PasswordResetsTest>'

Related

NoMethodError: undefined method `create_reset_digest' for #<User:0x007fba32e0af58>

I got these 5 errors upon doing a bundle rake exec test. I have no idea how to resolve it. I've googled and googled with no end in site (see what I did there). Now I turn to you for help!
If you accept, these are the errors:
1) Error:
PasswordResetsTest#test_password_resets:
NoMethodError: undefined method `create_reset_digest' for #<User:0x007fba32e0af58>
app/controllers/password_resets_controller.rb:12:in `create'
test/integration/password_resets_test.rb:17:in `block in <class:PasswordResetsTest>'
2) Error:
UsersLoginTest#test_login_with_valid_information_followed_by_logout:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba28cd32c0>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/users/show.html.erb:15:in `_app_views_users_show_html_erb___2170813965465965459_70218768032700'
test/integration/users_login_test.rb:14:in `block in <class:UsersLoginTest>'
3) Error:
UsersProfileTest#test_profile_display:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba2f8c51e0>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/users/show.html.erb:15:in `_app_views_users_show_html_erb___2170813965465965459_70218768032700'
test/integration/users_profile_test.rb:11:in `block in <class:UsersProfileTest>'
4) Error:
UsersIndexTest#test_index_as_admin_including_pagination_and_delete_links:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba2cdf19a0>:0x007fba28ed08e8>
app/views/users/_user.html.erb:4:in `_app_views_users__user_html_erb__3013593760514997339_70218798383040'
app/views/users/index.html.erb:7:in `_app_views_users_index_html_erb___1851646122892737362_70218763684120'
test/integration/users_index_test.rb:12:in `block in <class:UsersIndexTest>'
5) Error:
MicropostsInterfaceTest#test_micropost_interface:
ActionView::Template::Error: undefined method `current_user?' for #<#<Class:0x007fba312ac360>:0x007fba2ff66120>
app/views/microposts/_micropost.html.erb:10:in `_app_views_microposts__micropost_html_erb___3978616761423832463_70218762096200'
app/views/shared/_feed.html.erb:3:in `_app_views_shared__feed_html_erb___1999510692289199836_70218832039180'
app/views/static_pages/home.html.erb:13:in `_app_views_static_pages_home_html_erb__315324690869897794_70218832802580'
test/integration/microposts_interface_test.rb:11:in `block in <class:MicropostsInterfaceTest>'
BACKSTORY: I ignored these errors messages as I went through a few of the chapters. I'm not sure if it popped up between 9, 10, or 11. I am new to programming so I don't know if this is enough information for you to be able to help me. The deeper I get into programming material the more it all seems confusing. SOS
I suppose you are following the https://www.railstutorial.org
You have a recurring undefined method 'current_user' error in [2, 3, 4, 5]
Did you defined the current_user helper method as it should be done in your session_helper.rb ?

configure warden rails

I started my rails app and suddenly got the following error
/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise.rb:406:in `configure_warden!': undefined method `failure_app=' for nil:NilClass (NoMethodError)
devise.rb line 406 has:
warden_config.failure_app = Devise::Delegator.new
I cannot figure out the problem, how do i go about this?

rake db:populate rake aborted! undefined method `each' for nil:NilClass

I'm following the Rails tutorials from here.
But at chapter 12.2 when I'm running db:populate, I get this error on line 54:
rake aborted! undefined method `each' for nil:NilClass
So okay following seems to be empty, but what should I do to fix it?
Here is my related code

NoMethodError: undefined method new for nil:NilClass

I’m facing a problem when trying to enter the list = list.new in the rails console. I get the following error message:
NoMethodError: undefined method `new’ for nil:NilClass
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.8/lib/active_support/whiny_nil.rb:48:in `method_missing’
from (irb):1
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands/console.rb:44:in `start’
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in `start’
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:23:in `’
from script/rails:6:in `require’
from script/rails:6:in `’
Any ideas why?
Thanks a lot!
Model names are capitalized by convention in Rails. Try this instead:
list = List.new
You should try this
#list = List.new

Rspec: undefined method `new' error in ActiveRecord model

I know this has to be something stupid, but I keep getting the following error in one of my examples:
undefined method `new' for #<Class:0x211d274>
I have created a simple example to show the error:
describe LateCharge do
before :each do
#membership = Membership.new
#location = mock_model(Location, :late_payment_rate => 10)
end
it "should initialize" do
LateCharge.respond_to?('new').should == true
#charge = LateCharge.new(#membership, #location)
end
end
The strange part is, when I run the example by itself, it passes. When I run it with all my examples, it fails with the following error:
NoMethodError in 'LateCharge should initialize'
undefined method `new' for #<Class:0x211d274>
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1964:in `method_missing_without_paginate'
/Users/l33/.gem/ruby/1.8/gems/mislav-will_paginate-2.3.11/lib/will_paginate/finder.rb:170:in `method_missing'
./spec/models/late_charge_spec.rb:15:
It is failing on the line: #charge = LateCharge.new(#membership, #location)
I do not have any problems instantiating the LateCharge object at run time or from the console.
Anyone have any ideas?
Seems to me the following information is key to your issue:
will_paginate/finder.rb:170:in `method_missing'
Hey Lee - not sure if you're still having this problem, but I had the exact same thing and it's because another spec I had was unstubbing the function.

Resources