Class: Wallaby::ResourcesRouter
- Inherits:
-
Object
- Object
- Wallaby::ResourcesRouter
- Defined in:
- app/routes/wallaby/resources_router.rb
Overview
This is the core of wallaby that dynamically dispatches request to appropriate controller and action.
Instance Method Summary collapse
-
#call(env) ⇒ Object
It tries to find out the controller that has the same model class from converted resources name.
Instance Method Details
#call(env) ⇒ Object
It tries to find out the controller that has the same model class from converted resources name. Otherwise, it falls back to generic controller ‘Wallaby::ResourcesController`.
10 11 12 13 14 15 16 17 18 19 |
# File 'app/routes/wallaby/resources_router.rb', line 10 def call(env) params = env[ActionDispatch::Http::Parameters::PARAMETERS_KEY] controller = find_controller_by params[:resources] params[:action] = find_action_by params controller.action(params[:action]).call env rescue ::AbstractController::ActionNotFound, ModelNotFound => e params[:error] = e ResourcesController.action(:not_found).call env end |