railstutorial.org - Rails: uninitialized constant (NameError) -
i stuck in chapter 11 of rails tutorial ("section 11.2.5 working follow button ajax"). getting
relationships_controller_spec.rb:3:in `<top (required)>': uninitialized constant relationshipscontroller (nameerror)
here controller spec (/sample_app/spec/controllers/relationships_controller_spec.rb) error complains line 3:
require 'spec_helper' describe relationshipscontroller let(:user) {factorygirl.create(:user)} let(:other_user) {factorygirl.create(:user)} before {sign_in user, no_capybara: true} describe "create relationship ajax" "should increment relationship count" expect xhr :post, :create, relationship: { followed_id: other_user.id} end.to change(relationship, :count).by(1) end "should respond success" xhr :post, :create, relationship: {followed_id: other_user.id} expect(response).to be_success end end describe "destroying relationship ajax" before {user.follow!(other_user)} let(:relationship) user.relationships.find_by(followed_id: other_user.id) end "should decrement relationship count" expect xhr :delete, :destroy, id: relationship.id end.to change(relationship, :count).by(-1) end "should respond success" xhr :delete, :destroy, id: relationship.id expect(response).to be_success end end end
here controller (/sample_app/app/controllers/relatonships_controller.rb) itself:
class relationshipscontroller < applicationcontroller before_action :signed_in_user def create @user = user.find(params[:relationship][:followed_id]) current_user.follow!(@user) #redirect_to @user replaced code below: respond_to |format| format.html {redirect_to @user} format.js end end def destroy @user = relationship.find(params[:id]).followed current_user.unfollow!(@user) #redirect_to @user replaced code below: respond_to |format| format.html {redirect_to @user} format.js end end end
what doing wrong?
you have typo in filename: /relatonships, no between relat , onships.
ruby-on-rails-4 railstutorial.org
No comments:
Post a Comment