使用PUMA的Rails,将localhost:3000更改为localhost:3000 / example

安东尼奥·巴斯克斯

我已经开发了可以在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)。

有人知道我该如何解决吗?提前致谢

尼耶什·乔西(Nijeesh Joshy)

将整个路由配置包装在 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法使用Rails ping http:// localhost:3000

为什么Puma监听'tcp:// localhost:3000'而不是'http:// localhost:3000'

将localhost:3280 / some / long / url镜像到localhost:3000

当我尝试访问URL时,Rails日志在Puma的终端中未显示任何内容:localhost:3000

如何使用RewriteBase将localhost更改为localhost / subdir?

Express.js 可以将 localhost:3000 和 localhost:3000/ 设置为不同的路由吗?

使用代理目标将用户从localhost:3000移至localhost:3000 / auth / google

无法在localhost:3000上获取/

无法访问localhost:3000 ruby on rails ubuntu

Nuxt JS 服务器部署 - 如何使用 htaccess 将 URL 重定向到 localhost:3000

$ .getJSON将'http:// localhost:3000'添加到api URL

是否可以将 React 应用程序用户从 127.0.0.1:3000 重定向到 localhost:3000?

为什么我不能在React中使用axios从localhost:3000调用localhost localhost:5000

如何将domain.com/en/example1更改为domain.com/english/example1

Chrome无法使用Gulp / BrowserSync打开localhost:3000

尝试在localhost:3000上使用Express运行脚本

部署Grafana时使用未知选项“ -L3000:localhost:3000”

http:// localhost / example / test.php无法正常工作?

反应代理错误:无法将请求/ api /从localhost:3000代理到http:// localhost:8000(ECONNREFUSED)

代理错误:无法将请求/付款从localhost:3000代理到https:// localhost:5000 /

代理错误:无法将请求 /users 从 localhost:3000 代理到 http://localhost:3001/

将 url http://example.com 改为 Https://www.example.com

如何从http:// localhost:3000访问Firebase

POST http:// localhost:3000/404(未找到)

带有AngularFire的localhost:3000 / traceur SystemJS

nodeJS请求POST到localhost:3000 ECONNREFUSED

Node.js localhost:3000 拒绝连接

无法访问 http://localhost:3000/

localhost:3000未呈现节点教程