Method: ActionDispatch::Routing::RouteSet::Generator#normalize_options!

Defined in:
actionpack/lib/action_dispatch/routing/route_set.rb

#normalize_options!Object



745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 745

def normalize_options!
  # If an explicit :controller was given, always make :action explicit too, so
  # that action expiry works as expected for things like
  #
  #     generate({controller: 'content'}, {controller: 'content', action: 'show'})
  #
  # (the above is from the unit tests). In the above case, because the controller
  # was explicitly given, but no action, the action is implied to be "index", not
  # the recalled action of "show".

  if options[:controller]
    options[:action]     ||= "index"
    options[:controller]   = options[:controller].to_s
  end

  if options.key?(:action)
    options[:action] = (options[:action] || "index").to_s
  end
end