Question about environments and rake

Hi,

Short version:
How do I specify an environment (as in, development, production, or in
my case, a custom environment) to the command 'rake db:migrate?'

Long version:
A friend and I are putting together a web app using Ruby on Rails. We
wanted to both have our own development instances running to play
with, each that could be configured slightly differently. So what we
ended up doing was creating two environments -- user1_development, and
user2_development -- with their own environment files, and their own
listings in config/databases.yml. We wanted each of these instances to
have their own databases, so the entry in databases.yml for
user1_development, for instance, is identical to that for the
"development" environment, except instead of the database being named
"projectname_development" it's named "projectname_user1_development."

We're using mongrel and each have our own mongrel_cluster.yml files
that specify our respective environments, so that all works fine.

The problem is with rake db:migrate. I cannot figure out how to get
rake to run in a custom environment; so, for instance, when I do a
rake db:migrate, I don't know how to get it to migrate database
"projectname_user1_development" instead of "projectname_development."
Does anyone have any idea how to do this?

Thanks very much,
Paul Eastlund

Short version:
How do I specify an environment (as in, development, production, or in
my case, a custom environment) to the command 'rake db:migrate?'

rake db:migrate RAILS_ENV=production

Long version:
A friend and I are putting together a web app using Ruby on Rails. We
wanted to both have our own development instances running to play
with, each that could be configured slightly differently. So what we
ended up doing was creating two environments -- user1_development, and
user2_development -- with their own environment files, and their own
listings in config/databases.yml. We wanted each of these instances to

Is the only difference b/n your sites database.yml? Is so, why not commit
a database.yml-sample and then svn-ignore database.yml and just set it to
what you want.

That works well for us... and allows us to all use "development"...

Not saying you have to, just pointing out another option.

Short version:
How do I specify an environment (as in, development, production, or in
my case, a custom environment) to the command ‘rake db:migrate?’

rake db:migrate RAILS_ENV=production

Thanks for the tip! This worked like a charm.

Is the only difference b/n your sites database.yml? Is so, why not commit
a database.yml-sample and then svn-ignore database.yml and just set it to
what you want.

That works well for us… and allows us to all use “development”…

Not saying you have to, just pointing out another option.

Thanks for the suggestion. No, there’s also some minor differences between our config/environments files. The chief other issue was this: I want to have a non-secure page that contains a form that the user can fill secure data into. In HTML terms, this just means that the form tag needs a URL that starts with “https://” but there’s no way to specify the protocol without specifying the domain, which means each of our apps needs to know the domain it’s being hosted at. Since Rails has no knowledge of this already, and the two apps are at slightly different domains, we put this data in the environment files – so config/environments/user1.rb has the line DOMAIN="
user1.oursite.com", for instance. It’s a little bit of a hack, but we searched around online and couldn’t find a prettier solution. Please let me know if you have one.

-Paul