This method is deprecated or moved on the latest stable version.
The last existing version (v2.3.8) is shown here.
ensure_required_segments(segments)
public
Makes sure that there are no optional segments that precede a required
segment. If any are found that precede a required segment, they are made
required.
# File actionpack/lib/action_controller/routing/builder.rb, line 140
def ensure_required_segments(segments)
allow_optional = true
segments.reverse_each do |segment|
allow_optional &&= segment.optional?
if !allow_optional && segment.optional?
unless segment.optionality_implied?
warn "Route segment \"#{segment.to_s}\" cannot be optional because it precedes a required segment. This segment will be required."
end
segment.is_optional = false
elsif allow_optional && segment.respond_to?(:default) && segment.default
# if a segment has a default, then it is optional
segment.is_optional = true
end
end
end