Posted over 3 years ago. Visible to the public. Repeats.

Rails: Namespacing controller classes without affecting routes

When you want to namespace your controller classes (group some controllers into a folder) but leave the corresponding routes unaffected, you can use the scope method like follows:

Copy
scope module: 'proxy' do resources :properties end
  • URL: /properties
  • Route helper: proxy_properties_path
  • Controller class: Proxy::PropertiesController

Also see Rails: Namespacing URLs without affecting controllers and route helpers

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Author of this card:

Avatar
Andreas Robecke
Last edit:
over 1 year ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Andreas Robecke to makandropedia