Class: Wallaby::ResourcesRouter

Inherits:
Object
  • Object
show all
Defined in:
app/routes/wallaby/resources_router.rb

Constant Summary collapse

DEFAULT_CONTROLLER =
Wallaby::ResourcesController

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'app/routes/wallaby/resources_router.rb', line 30

def call(env)
  params          = env['action_dispatch.request.path_parameters']
  controller      = find_controller_by params[:resources]
  params[:action] = find_action_by params

  controller.action(params[:action]).call env
rescue AbstractController::ActionNotFound, Wallaby::ModelNotFound => e
  params[:error] = e
  DEFAULT_CONTROLLER.action(:not_found).call env
end