views:

364

answers:

2

One of our requirements was that all our url's ended with .html We've overridden the default_url_options method to add the format to the options

def default_url_options(options={})
  options.merge(:format => 'html')
end

This works great in the most part... but it causes issue with the following routes:

map.home '/', :controller => 'home'
map.root :controller => 'home'

it causes these routes to return:

domain.com/?format=html

I need to find a way to make an exception to these routes, is this possible or does anyone know a smarter way to do this.

Many thanks Rob

A: 

This seemed to work for me in a quick test.

map.home '/', :controller => 'home', :format => ''
Andy Gaskell
Implementing this on rails 2.3.2 gives me....Processing ApplicationController#index to (for 127.0.0.1 at 2009-08-17 09:50:45) [GET] Parameters: {"format"=>"", "action"=>"index", "controller"=>"home"}ArgumentError (interning empty string): /opt/local/lib/ruby/gems/1.8/gems/haml-edge-2.1.12/lib/haml/helpers/action_view_mods.rb:14:in `render'
Rob
yeah, I didn't try it with haml - sorry.
Andy Gaskell
no worries, it must be something to do with the way haml hooks into render
Rob
+1  A: 

Well this make it work with haml... (erb untested)

map.home '/', :controller => 'home', :format => 'html'
Rob