Rails 3.1 force .html instead of no extension

二次信任 提交于 2019-12-03 16:23:12

Just as Mattias Wadman suggested, in config/application.rb add:

AppName::Application.default_url_options = { :format => "html" }

But also change config/routes.rb to:

root :to => 'pages#home', :defaults => { :format => "html" }

Im no Rails routing expert but I tried to force HTML format by changing the default URL options and at least the URL helpers seams to generate .html URLs now, it's a start.

config/application.rb (at the bottom)

AppName::Application.default_url_options = {:format => "html"}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!