railstutorial.org - NoMethodError rails couldn't find my method 'feed' - Rails Tutorial -


i following rails tutorial , told type in static pages controller:

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

here result of rspec tests:

failures:    1) static pages home page signed in users should render user's feed      ←[31mfailure/error:←[0m ←[31mvisit root_path←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x5ae7480>←[0m ←[36m     # ./app/controllers/static_pages_controller.rb:6:in `home'←[0m ←[36m     # ./spec/requests/static_pages_spec.rb:29:in `block (4 levels) in <top (required)>'←[0m    2) user      ←[31mfailure/error:←[0m ←[31mit { should respond_to(:feed) }←[0m        ←[31mexpected #<user id: nil, name: "tim green", email: "timgreen1@outlook.com", created_at: nil, updated_at: nil, password_digest: "$2a$04$5zt aqlxq5e6zt5du.ggmaes2qv9yplobdwjixxu8wkjn...", remember_token: nil, admin: false> respond :feed←[0m ←[36m     # ./spec/models/user_spec.rb:32:in `block (2 levels) in <top (required)>'←[0m    3) user micropost associations status feed      ←[31mfailure/error:←[0m ←[31mits(:feed) { should_not include(unfollowed_post) }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x5bb1c80>←[0m ←[36m     # ./spec/models/user_spec.rb:173:in `block (4 levels) in <top (required)>'←[0m    4) user micropost associations status feed      ←[31mfailure/error:←[0m ←[31mits(:feed) { should include(older_micropost) }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x5bdfdd8>←[0m ←[36m     # ./spec/models/user_spec.rb:172:in `block (4 levels) in <top (required)>'←[0m    5) user micropost associations status feed      ←[31mfailure/error:←[0m ←[31mits(:feed) { should include(newer_micropost) }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x5c6f718>←[0m ←[36m     # ./spec/models/user_spec.rb:171:in `block (4 levels) in <top (required)>'←[0m    6) authentication authorization wrong user visiting edit page different user      ←[31mfailure/error:←[0m ←[31mbefore { visit edit_user_path(wrong_user) }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x6149358>←[0m ←[36m     # ./app/controllers/static_pages_controller.rb:6:in `home'←[0m ←[36m     # ./spec/requests/authentication_pages_spec.rb:110:in `block (5 levels) in <top (required)>'←[0m    7) micropost pages micropost creation invalid information should not create micropost      ←[31mfailure/error:←[0m ←[31mbefore { visit root_path }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x61a3df0>←[0m ←[36m     # ./app/controllers/static_pages_controller.rb:6:in `home'←[0m ←[36m     # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'←[0m    8) micropost pages micropost creation invalid information error messages      ←[31mfailure/error:←[0m ←[31mbefore { visit root_path }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x43aaba0>←[0m ←[36m     # ./app/controllers/static_pages_controller.rb:6:in `home'←[0m ←[36m     # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'←[0m    9) micropost pages micropost creation valid information should create micropost      ←[31mfailure/error:←[0m ←[31mbefore { visit root_path }←[0m      ←[31mnomethoderror:←[0m        ←[31mundefined method `feed' #<user:0x5a73f50>←[0m ←[36m     # ./app/controllers/static_pages_controller.rb:6:in `home'←[0m ←[36m     # ./spec/requests/micropost_pages_spec.rb:11:in `block (3 levels) in <top (required)>'←[0m  finished in 7.74 seconds ←[31m114 examples, 9 failures←[0m 

basically returning nomethoderror 'feed' method, understand error can't find define method , how it, baring in mind return news feed, help?

the errors give hints. one:

undefined method `feed' #<user:0x5ae7480> 

shows have instance of class user , code trying find instance method named feed on instance of user.

there's failing test testing directly:

expected #<user id: nil, name: "tim green", email: "timgreen1@outlook.com",  created_at: nil, updated_at: nil, password_digest: "$2a$04$5ztaqlxq5e6zt5du.ggmaes2qv9yplobdwjixxu8wkjn...",  remember_token: nil, admin: false> respond :feed 

this in user_spec.rb , explicitly saying user instance should respond message (which way of saying "method call") named feed.

this means need go user.rb , add def feed , implement method return want return.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -