有在10.3.1 Access control與測試問題:railstutorial 10.3.1:未定義的局部變量或方法`microposts_path '`micropost_path'
Failures:
1) Authentication authorization for non-signed-in users in the Microposts controller submitting to the destroy action
Failure/Error: before { delete micropost_path(FactoryGirl.create(:micropost)) }
NoMethodError:
undefined method `micropost_path' for #<RSpec::Core::ExampleGroup::Nested_3::Nested_3::Nested_1::Nested_3::Nested_2:0x00000004edd970>
# ./spec/requests/authentication_pages_spec.rb:117:in `block (6 levels) in <top (required)>'
2) Authentication authorization for non-signed-in users in the Microposts controller submitting to the create action
Failure/Error: before { post microposts_path }
NameError:
undefined local variable or method `microposts_path' for #<RSpec::Core::ExampleGroup::Nested_3::Nested_3::Nested_1::Nested_3::Nested_1:0x0000000521c758>
# ./spec/requests/authentication_pages_spec.rb:112:in `block (6 levels) in <top (required)>'
我routes.rb
這個附加:
resources :misroposts, only: [:create, :destroy]
但不幫忙。什麼意思undefined method 'micropost_path'
?我不知道該怎麼辦。
對不起,我提出了其他問題。是的,我有'資源:misroposts,只:[:創建,:銷燬]'。 'rake routes' have paths: 'misroposts POST /misroposts(.:format)misroposts#create' 'misropost DELETE /misroposts/:id(.:format)misroposts#destroy' –
哦,看起來你有一個錯字。它應該用'c而不是'misroposts'來表示'microposts'。 – najwa
Facepalm!謝謝。 –