rails default_url_options for ActionController以自动格式化所有URL/path用.html
-
16-09-2019 - |
题
我们的要求之一是,我们所有的URL以.html结尾
def default_url_options(options={})
options.merge(:format => 'html')
end
这在大多数情况下都可以很好地工作...但是它会导致以下路线问题:
map.home '/', :controller => 'home'
map.root :controller => 'home'
它导致这些路线返回:
domain.com/?format=html
我需要找到一种使这些路线例外的方法,这是可能的还是任何人都知道这样做的更聪明的方法。
解决方案
好吧,这使其与Haml一起使用...(ERB未经测试)
map.home '/', :controller => 'home', :format => 'html'
其他提示
在快速测试中,这似乎对我有用。
map.home '/', :controller => 'home', :format => ''
不隶属于 StackOverflow