ruby-on-rails – Rails应用程序中的前缀URL
发布时间:2020-12-17 03:19:32 所属栏目:百科 来源:网络整理
导读:我希望我的2.3 Rails应用程序中的所有页面都有以前缀为url的URL: www.example.com/app/ 我在routes.rb写了以下几行: # I named the first part of the url ':appl'map.root :appl = "app",:controller = "home"# Default routesmap.connect ':appl/:contro
我希望我的2.3 Rails应用程序中的所有页面都有以前缀为url的URL:
www.example.com/app/ 我在routes.rb写了以下几行: # I named the first part of the url ':appl' map.root :appl => "app",:controller => "home" # Default routes map.connect ':appl/:controller/:action/:id' map.connect ':appl/:controller/:action/:id.:format' 这一切都很好,除了map.resources,我有 map.resources :pages 现在无论我有edit_page_path或page,生成的url都不正确,因为app在开头没有插入.我已尝试使用命名空间和范围,就像我见过here in chapter 2.6,但没有成功. 我该怎么做?路由中的:appl是个坏主意吗? 解决方法
如果要在Passenger上部署,则只需设置(在您的Web服务器配置中):
RailsBaseURI / app 然后在你的应用程序配置中: config.action_controller.relative_url_root = '/app' 你不应该担心除此之外的任何子项目.它应该工作.有关详细信息,请参阅Passenger documentation. 对于mongrel,您可以使用–prefix选项 script/server mongrel -P /app (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |