开发者

Prefix all urls with virtual folder name

I'm trying to deploy my RoR 3.0 application on a server that is not supported by Passenger. Everything worked fine until I decided to use an Apache virtual folder for my application server. On the production environment I now have to manually add the folder name in front of all URL, for instance using a :host => "myServer/myApp" in all url_for calls. It works but it is painful. Does anybody know a nice way to automate it?    

Here what I tried unsuccessfully so far after rea开发者_StackOverflow社区ding many posts:

  • define default_url_for { :host => "myServer/myApp" } in application.rb, but had no effect

  • I found some indication to define url_for and call super from inside it. No effect either

Thanks for your help

Hadrien


The quick and dirty solution is to wrap everything inside a scope block in your config/routes.rb file:

scope 'myApp' do  # replace 'myApp' with the virtual folder name

  resources :users
  # ...

end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜