Method: ActionDispatch::Routing::Mapper#rest_root
- Defined in:
- lib/rest_framework/routers.rb
#rest_root(path = nil, **kwargs, &block) ⇒ Object
Route a controller’s ‘#root` to ’/‘ in the current scope/namespace, along with other actions.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/rest_framework/routers.rb', line 116 def rest_root(path=nil, **kwargs, &block) # by default, use RootController#root root_action = kwargs.delete(:action) || :root controller = kwargs.delete(:controller) || path || :root path = path.to_s # route the root get path, controller: controller, action: root_action # route any additional actions controller_class = self._get_controller_class(controller, pluralize: false) controller_class.extra_actions.each do |action, methods| methods = [methods] if methods.is_a?(Symbol) || methods.is_a?(String) methods.each do |m| public_send(m, File.join(path, action.to_s), controller: controller, action: action) end yield if block_given? end end |