我已经开发了可以在http:// localhost:3000 /中正常工作的Rails 5应用程序
现在,我需要此应用程序从localhost:3000 / example启动,并且链接通过此新主机(例如localhost:3000 / example / users / new)进行。我已经知道资产和javascripts在localhost:3000 / example中可以正常工作:
config.root_path = '/example'
但是链接仍会重定向到旧链接(例如localhost:3000 / users / new)。
有人知道我该如何解决吗?提前致谢
将整个路由配置包装在 scope
#config/routes.rb
Rails.application.routes.draw do
scope '/example' do
#all the routes goes here
end
end
您可以以此更改资产的交付路径
有关更多信息:https : //guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
#config/application.rb
config.action_controller.asset_host = "example.com"
config.assets.prefix = '/example'
https://guides.rubyonrails.org/v3.0.3/configuring.html#configuring-action-controller
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句