Search code examples
ruby-on-railsurl-rewritingfriendly-urlactioncontroller

Rails default_url_options for actioncontroller to auto format all urls/paths with .html


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.


Solution

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

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