Reputation: 3400
I'm currently using Pow to manage my Rails app, and have both .dev and .test running. I was wondering how to set up .test domain to use the test database instead of the development one.
Basically, can I have appname.dev with a development environment loaded, and appname.test with a test environment?
Upvotes: 2
Views: 451
Reputation: 10874
You might be able to use a variation of this Gist to determine the domain being accessed, and have the Rails app behave accordingly from then on.
You'd add a before_filter on your Application Controller that sets session[:site]
according to whether it's a development or testing environment (with the option to pass either site=development
or site=testing
from the standard Rails server as well).
Here's what I think would be the relevant excerpt of the Gist linked above:
session[:site] = case request.domain
when "appname.dev" then "development"
when "appname.test" then "testing"
else ENV['site'] || "development"
end
The rest of your Rails app would behave according to the value of session[:site]
. I wrote a bit more about multi-site Rails apps here, as well.
Upvotes: 1