How does the :default option differ from just setting the key value
pair at the end of the route?
For example:
map.connect ''index/test/:foo/:bar'', :controller =>
''index'', :action =>
''test'', :defaults => { :foo => ''foo'',
:bar => ''bar'' }
map.connect ''index/test/:foo/:bar'', :controller =>
''index'', :action =>
''test'', :foo => ''foo'', :bar =>
''bar''
What is the point of using defaults? They both seem to work as
intended? Thank you
Note: I looked at the Ruby on Rails Routing guide and I tried the
following example from (http://guides.rubyonrails.org/routing.html)
map.connect ''photos/:id'', :controller =>
''photos'', :action =>
''show'', :defaults => { :format =>
''jpg'' }
and I get the following error:
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/builder.rb:107:in `assign_route_options'': format: No matching
segment exists; cannot assign default (ArgumentError)
It looks like I need to actually have :format defined as part of the
url. Did something change recently? I am using rails 2.3.2