method
default_controller_and_action
v4.0.2 -
Show latest stable
-
0 notes -
Class: ActionDispatch::Routing::Mapper::Mapping
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
default_controller_and_action()
private
Hide source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 204 def default_controller_and_action if to.respond_to?(:call) { } else if to.is_a?(String) controller, action = to.split('#') elsif to.is_a?(Symbol) action = to.to_s end controller ||= default_controller action ||= default_action unless controller.is_a?(Regexp) controller = [@scope[:module], controller].compact.join("/").presence end if controller.is_a?(String) && controller =~ %{\A/} raise ArgumentError, "controller name should not start with a slash" end controller = controller.to_s unless controller.is_a?(Regexp) action = action.to_s unless action.is_a?(Regexp) if controller.blank? && segment_keys.exclude?(:controller) raise ArgumentError, "missing :controller" end if action.blank? && segment_keys.exclude?(:action) raise ArgumentError, "missing :action" end if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/ message = "'#{controller}' is not a supported controller name. This can lead to potential routing problems." message << " See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use" raise ArgumentError, message end hash = {} hash[:controller] = controller unless controller.blank? hash[:action] = action unless action.blank? hash end end