extract controller and action parsing to a method
This commit is contained in:
parent
bc916a7e58
commit
8d309832df
@ -240,25 +240,12 @@ def default_controller_and_action
|
||||
hash = {}
|
||||
return hash if to.respond_to? :call
|
||||
|
||||
controller = default_controller
|
||||
action = default_action
|
||||
|
||||
case to
|
||||
when Symbol
|
||||
action = to.to_s
|
||||
when /#/
|
||||
controller, action = to.split('#')
|
||||
when String
|
||||
controller = to
|
||||
end
|
||||
|
||||
if @scope[:module] && !controller.is_a?(Regexp)
|
||||
if controller =~ %r{\A/}
|
||||
controller = controller[1..-1]
|
||||
else
|
||||
controller = [@scope[:module], controller].compact.join("/")
|
||||
end
|
||||
end
|
||||
controller, action = get_controller_and_action(
|
||||
default_controller,
|
||||
default_action,
|
||||
to,
|
||||
@scope[:module]
|
||||
)
|
||||
|
||||
if controller.is_a? Regexp
|
||||
hash[:controller] = controller
|
||||
@ -277,6 +264,26 @@ def default_controller_and_action
|
||||
hash
|
||||
end
|
||||
|
||||
def get_controller_and_action(controller, action, to, modyoule)
|
||||
case to
|
||||
when Symbol
|
||||
action = to.to_s
|
||||
when /#/
|
||||
controller, action = to.split('#')
|
||||
when String
|
||||
controller = to
|
||||
end
|
||||
|
||||
if modyoule && !controller.is_a?(Regexp)
|
||||
if controller =~ %r{\A/}
|
||||
controller = controller[1..-1]
|
||||
else
|
||||
controller = [modyoule, controller].compact.join("/")
|
||||
end
|
||||
end
|
||||
[controller, action]
|
||||
end
|
||||
|
||||
def check_action!(action)
|
||||
unless action || segment_keys.include?(:action)
|
||||
message = "Missing :action key on routes definition, please check your routes."
|
||||
|
Loading…
Reference in New Issue
Block a user