Rails: using path on a resource in routes causes tests to fail and “Method Not Allowed” error

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Rails: using path on a resource in routes causes tests to fail and “Method Not Allowed” error



In my routes, I have:


resources :company_ads
resources :company_videos
resources :company_trivia



When I change this to:


resources :company_ads, path: '/assets/ads'
resources :company_videos, path: '/assets/videos'
resources :company_trivia, path: '/assets/trivia'



I can visit the URL as expected and see, for example, an index of the ads at localhost:3000/assets/ads



However, it's causing my tests to fail


CompanyTriviaControllerTest#test_should_get_index [.../test/controllers/company_trivia_controller_test.rb:11]:
Expected response to be a <2XX: success>, but was a <302: Found> redirect to <http://www.example.com/auth/login>
Response body: <html><body>You are being <a href="http://www.example.com/auth/login">redirected</a>.</body></html>



And when I try to update one of these models, I get a "Method not allowed" error. As soon as I remove the path, all goes back to normal.



I'm confused, as the documentation sure seems to suggest I'm doing this correctly.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty