Posted almost 6 years ago. Visible to the public.

How to fix routing error when using concerns in Rails up to


  • Don't write resources :people, :concerns => :trashable

  • Write

    resources :people do concerns :trashable end


Writing a controller spec I encountered this error:

Failure/Error: get :index ActionController::RoutingError: No route matches {:controller=>"people"}

caused by this route definition

resources :people, :concerns => :trashable

which renders strange routes:

trash_person PUT /people/:id/trash(.:format) people#check {:concerns=>:trashable} people GET /people(.:format) people#index {:concerns=>:trashable} POST /people(.:format) people#create {:concerns=>:trashable} new_person GET /people/new(.:format) people#new {:concerns=>:trashable} edit_person GET /people/:id/edit(.:format) people#edit {:concerns=>:trashable} person GET /people/:id(.:format) people#show {:concerns=>:trashable} PUT /people/:id(.:format) people#update {:concerns=>:trashable} DELETE /people/:id(.:format) people#destroy {:concerns=>:trashable}

Note the {:concerns=>:trashable} at the end of each route.

The fix

… was to write the routes with another syntax …

resources :people do concerns :trashable end

… and now my routes are fine.

Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.

Join our free training event and learn to fix any flaky test suite, even in large legacy applications.

Owner of this card:

Martin Straub
Last edit:
almost 6 years ago
by Martin Straub
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Straub to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more