user14069773
user14069773

Reputation: 175

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.

Upvotes: 0

Views: 257

Answers (1)

hashrocket
hashrocket

Reputation: 2222

In the controller, you can access :host with params[:host].

Upvotes: 1

Related Questions