On 29. mai. 2009, at 19.06, prlawrence wrote:
> I am very confused. We saw that when I created the repository
> something appeared in the development.log file. So why are these in
> the production database? Why do I even have to have a test, dev, and
> prod database? I don't want to develop gitorious (at least for now).
> I only want to use it, in one production database.
Yes, this can be really confusing, I'll try to explain what's going on.
Rails lets you operate with several environments in the same
application. The most obvious example is the test environment:
whenever you run your unit/functional tests, Rails will delete all the
data in your (test) database and recreate a predictable data set for
you. Similarly, when you're running an application in development
mode, you'll want some things to behave differently (for instance, all
Ruby classes are reloaded on every request to the web server), and use
a separate database.
Thus the distinction between different environments in Rails.
Whenever Rails - or a script using Rails - is started, it will try to
figure out which environment you want to use.
- If you run the tests, using Rake, Rails will assume you want the
test environment
- Otherwise, unless you specify otherwise, Rails will load the
development environment - which is the default.
- By "specifying otherwise" I mean either setting the environment
variable RAILS_ENV to either test, development or production og
setting the environment in Ruby code
So: if you're running a server, you'll probably want to use the
production environment when doing so. If you run you app under
Passenger, this will probably be the default. But if you start a
script from the command line (eg. script/poller), this will load the
default environment (development) unless you specify something else.
What we do on gitorious.org is something like:
env RAILS_ENV=production script/poller start
This will load Gitorious using the production Rails environment.
Hope this helps,
- Marius
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Gitorious" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/gitorious?hl=en
-~----------~----~----~----~------~----~------~--~---