ruby-on-rails - Rails - Controller route with hostname parameter
问题描述
I have two hosts my application gets deployed to
host1
host2
I want to expose a route that takes a host parameter to connect me to the correlating host. If I call myapp/myendpoint/host1
I want to call the app on host1
and vice versa, but I am struggling to write a route for this. I have tried:
get "controller/:host" => "controller#index"
But now stuck for how to handle the :host parameter in the controller and confirm it has hit the correct host.
解决方案
在控制器中,您可以:host
使用params[:host]
.
推荐阅读
- java - java继承和字符串插值
- python - 如何用python找到我的弹丸运动范围?
- python - 从 python Popen 运行 IDL .pro?
- excel - 使用 LEFT OUTER JOIN 的 SQL 查询语法错误
- azure - 如何在 Common Data Service 中进行批量插入?
- python - 返回彼此相等的两个数组的值的索引的最快方法是什么?
- azure - Azure Notification Hub compatible with Service Workers?
- javascript - 访问 this.state 后如何确保 setState 调用已经执行?
- tinymce - TinyMCE 插件文件选择器替换?
- javascript - 我无法在网络扩展中使用 express 和 fetch