Quantcast
Channel: NoMethodError: undefined method `feed' for nil:NilClass - Stack Overflow
Viewing all articles
Browse latest Browse all 3

NoMethodError: undefined method `feed' for nil:NilClass

$
0
0

I am following the steps strictly of Ruby on Rails Tutorials by Michael Hartl now and I am stuck in Listing 11.45 of Chapter 11.3- Manipulating microposts. When I run rake test before next section 11.3.4-Destroying microposts, 5 errors appears with similar reasons. It is supposed to be green as tutorial claimed. I don't understand why and how to solve that.One 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' for 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, the method 'feed' is as below:

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

In app/controllers/static_pages_controller.rb, the code is as below:

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

In test/integration/users_login_test.rb line 18:

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

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images