ruby on rails - NoMethodError: undefined method `feed' for nil:NilClass -


i following steps strictly of ruby on rails tutorials michael hartl , stuck in listing 11.45 of chapter 11.3- manipulating microposts. when run rake test before next section 11.3.4-destroying microposts, 5 errors appears similar reasons. supposed green tutorial claimed. don't understand why , how solve that. 1 of 5 errors is:

error["test_login_with_invalid_information", userslogintest, 2015-05-31 06:10:56 -0400] test_login_with_invalid_information#userslogintest (1433067056.81s) nomethoderror: nomethoderror: undefined method 'feed' nil:nilclass app/controllers/static_pages_controller.rb:4:in 'home' test/integration/users_login_test.rb:18:in 'block in class:userslogintest'

in app/models/user.rb, method 'feed' below:

 def feed   micropost.where("user_id = ?", id) end 

in app/controllers/static_pages_controller.rb, code below:

def home   if logged_in?     @micropost  = current_user.microposts.build     @feed_items = current_user.feed.paginate(page: params[:page])   end end 

in test/integration/users_login_test.rb line 18:

test "login invalid information"   login_path   assert_template 'sessions/new'   post login_path, session: { email: "", password: "" }   assert_template 'sessions/new'   assert_not flash.empty?   root_path            <- line 18   assert flash.empty? end 

the error happening on page root_path.

current_user not defined (is nil), method call current_user.feed in controller failing.

somewhere in code, part of authentication process, value of current_user needs set. experience done in application_controller.rb.

are sure these steps not in tutorial?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -