Misha Moroshko
Misha Moroshko

Reputation: 171321

How to tell Rails to work with the production database (rather than development one) when deploying?

I'm trying to upload my Rails 3 application to real production environment. (The application works perfectly on my local machine).

When I run rails c I got the following error:

/home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified)
        from /home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
        from /home/misha_moroshko/.gems/gems/activerecord-3.0.1/lib/active_record/railtie.rb:59
        from /home/misha_moroshko/.gems/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'

How should I tell Rails that it should work with the production database rather than the development one ?

Upvotes: 6

Views: 9913

Answers (3)

Chris Cherry
Chris Cherry

Reputation: 28554

Set the RAILS_ENV environment variable first, or pass it to the rails c command:

RAILS_ENV=production rails c

OR

rails c production

Upvotes: 21

corroded
corroded

Reputation: 21564

what's in your database.yml? it should have a production setting and you'll need to tell rails you want to run it in production:

rails c production

Upvotes: 4

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38012

This depends greatly on the 'environment' you are deploying to. For Apache and Passenger, one would set:

# conf/passenger.conf
RailsEnv production
RackEnv production

Upvotes: 1

Related Questions