Class: Wallaby::ResourcesRouter
- Inherits:
-
Object
- Object
- Wallaby::ResourcesRouter
- Defined in:
- lib/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`.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/routes/wallaby/resources_router.rb', line 11 def call(env) params = env[ActionDispatch::Http::Parameters::PARAMETERS_KEY] controller = find_controller_by(params[:resources]) || default_controller params[:action] = find_action_by params controller.action(params[:action]).call env rescue ::AbstractController::ActionNotFound, ModelNotFound => e params[:error] = e default_controller.action(:not_found).call env end |