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?
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 eithersite=developmentorsite=testingfrom the standard Rails server as well).Here’s what I think would be the relevant excerpt of the Gist linked above:
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.