NEW
-
roothelper will raise a syntax error indicating that it should be used outside ofmodular_routesblock. -
concernandconcernssupport:modular_routes do concern :commentable do resource :comments end concern :activatable do member do put :activate put :deactivate end end resources :articles, concerns: :activatable do concerns :commentable end end
REMOVED
modular_routehelper was removed due to lack of syntax flexibility and a bit of inline verbosity.
NEW
-
modular_routeshelper was added to fix the problems encountered on the previous helper. Check the example below:modular_routes do resources :books get :about, to: "about#index" end
The idea was to bring simplicity and proximity to what you already write in your routes file.
-
namespacesupport`namespace :v1 do resources :books end
It falls back to Rails default behavior.
-
scopesupportscope :v1 do resources :books end scope module: :v1 do resources :books end
It falls back to Rails default behavior. In this example it recognizes
/v1/booksand/booksexpectingBooksControllerandV1::BooksControllerrespectively. -
Nested resources support
modular_routes do resources :books do resources :comments end end
It recognizes paths like
/books/1/comments/2. -
Standalone (non-resourceful) routes
modular_routes do get :about, to: "about#index" end
It expects
About::IndexControllerto exist incontrollers/about/index_controller.rb. They don't belong to a resourceful scope.If
todoesn't matchcontroller#actionpattern, it falls back to Rails default behavior.
- Initial release