You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Andrew Yaroshuk edited this page Jun 8, 2015
·
5 revisions
Routing
Amethyst has Rails-like approach to describe routes:
Base::App.routes.draw do |routes|
# maps GET "/" to "hello" action of IndexController
get "/", "index#hello"# maps GET, POST, PUT, DELETE "/bye" to "bye" action of IndexController
all "/bye", "index#bye"# maps POST "/form/ to "form" action of IndexController
post "/form/", "index#form"
register IndexController# registering controller in routerend
Note, /bye and /bye/ work slightly different. First matches /bye, /bye/, /bye_something, second is "strict",
and matches only /bye and /bye/. Both not matches /bye/something.
See how describe routes in application class.
Path params
You can specify params to be captured:
get "/users/:id", "users#show"
This parameter will be available at UsersController show action:
defshow
request.path_params["id"]
end
Controllers registering
After creating controllers you need to register them:
Base::App.routes.draw do |routes|
#routes describing here
register StoreController
register OtherControllerend