Rails Default_url_options ActionController의 자동 형식에 대한 모든 URL/경로 .html
-
16-09-2019 - |
문제
우리의 요구 사항 중 하나는 모든 URL이 .html로 끝났다는 것입니다. 옵션에 형식을 추가하기 위해 default_url_options 메소드를 재정의했습니다.
def default_url_options(options={})
options.merge(:format => 'html')
end
이것은 대부분 훌륭하게 작동하지만 다음 경로에서 문제를 일으 킵니다.
map.home '/', :controller => 'home'
map.root :controller => 'home'
이 경로가 반환됩니다.
domain.com/?format=html
이 경로를 예외로 만들 수있는 방법을 찾아야합니다. 이것이 가능하거나 누구나이 작업을 더 똑똑한 방법을 알고 있습니까?
해결책
이것은 Haml과 함께 작동하게합니다 ... (Erb Untested)
map.home '/', :controller => 'home', :format => 'html'
다른 팁
이것은 빠른 테스트에서 저에게 효과가있는 것 같습니다.
map.home '/', :controller => 'home', :format => ''
제휴하지 않습니다 StackOverflow