RESTful Resources How to setup RESTful resources for Hanami
RESTful Resources
Hanami supports advanced features for RESTful resources:
# apps/web/config/routes.rb
resources :books, only: [:new, :create, :show] do
member do
get "toggle"
end
collection do
get "search"
end
end
The example above will generate the following named routes:
Name Method Path Action
toggle_book GET, HEAD /books/:id/toggle Web::Controllers::Books::Toggle
search_books GET, HEAD /books/search Web::Controllers::Books::Search
new_book GET, HEAD /books/new Web::Controllers::Books::New
books POST /books Web::Controllers::Books::Create
book GET, HEAD /books/:id Web::Controllers::Books::Show
Learn more at Routing RESTful guide.
Twitter Facebook