The OptionalFormatSegment allows for any resource route to have an optional :format, which decreases the amount of routes created by 50%.
Methods
Public Class methods
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 312 312: def initialize(key = nil, options = {}) 313: super(:format, {:optional => true}.merge(options)) 314: end
Public Instance methods
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 328 328: def extract_value 329: "#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase" 330: end
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 316 316: def interpolation_chunk 317: "." + super 318: end
the value should not include the period (.)
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 333 333: def match_extraction(next_capture) 334: %[ 335: if (m = match[#{next_capture}]) 336: params[:#{key}] = URI.unescape(m.from(1)) 337: end 338: ] 339: end
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 320 320: def regexp_chunk 321: '/|(\.[^/?\.]+)?' 322: end
[ show source ]
# File actionpack/lib/action_controller/routing/segments.rb, line 324 324: def to_s 325: '(.:format)?' 326: end