Topic: Deploying app to production environment

I have an app running fine on my laptop (my development machine) under Ubuntu 10.04 + Apache2 + Passenger.

I've moved the app to a  production machine also running  Ubuntu 10.04 Server version + Apache2 + Passenger.  Have set up virtual hosts correctly (as far  as I can tell) on production machine and  restarted  Apache2.

I can see the index.html file  in the app/public folder if I just http to the server host address.  However if  I then try to access any of the app itself  i.e. urls that connect via  controllers  and  display views then I get the default 500 message saying Sorry something has  gone wrong etc.

Please any help on what I'm doing wrong would be greatly appreciated.

Thanks  very much in advance.

Re: Deploying app to production environment

Did you check your production.log file for more details ?

Last edited by Javix (2010-09-14 11:34:16)

Re: Deploying app to production environment

The production log  has a whole bunch of stuff that I don't understand but the 3rd line down  says:

no such file  to load -- mysql.

What I did for mysql is a dump from my development m/c of schema.rb and  then  copied that over and  did  a  load of that into the database using rake.

Can't see what I've done  wrong there.  Thanks for your very prompt response.

Re: Deploying app to production environment

I've been doing some more digging and the production log is showing :

'unknown database xxx_development'

So rails thinks it's  in a development environment although when  I ran the rake db:create it correctly generated the xxx_production version of the database within mysql.

I have set the following in my environment.rb  file at the end:

ENV['RAILS_ENV']= 'production'

I also have the following in my virtualhost file  for the app:

RailsEnv production
RackEnv production

Any ideas on where else I should look to find out why Rails thinks it is in a development environment?  All help received  with gratitude and Thanks.

Re: Deploying app to production environment

Aaaargh!!  How many different ways are there to be called a Class 1 IDIOT.  I'll claim every one of them.

I had changed the database.yml file so that my production: tag appeared first then test: and  then development: but I didn't change the name of the actual database when I swapped the tags around.

Aaaaaargh again!!

However this does lead me to a  question.  Do I have to change the order of the databases in the database.yml file or should the system automatically pick up the right one from the environment.rb?  I can't remember now why I changed the sequence.

Re: Deploying app to production environment

nexar wrote:

Aaaargh!!  How many different ways are there to be called a Class 1 IDIOT.  I'll claim every one of them.

I had changed the database.yml file so that my production: tag appeared first then test: and  then development: but I didn't change the name of the actual database when I swapped the tags around.

Aaaaaargh again!!

However this does lead me to a  question.  Do I have to change the order of the databases in the database.yml file or should the system automatically pick up the right one from the environment.rb?  I can't remember now why I changed the sequence.

Order doesn't matter because rails will pick the correct environment from database.yml... just keep those db names under correct environment wink

Re: Deploying app to production environment

I'm assuming you don't have mysql gem installed on your production machine.

Re: Deploying app to production environment

OK I'm back again with a 'similar' problem.  I made some  more changes in my development environment and copied over the migration files to the production environment.  Now when  I try to run rake db:migrate it says

'Unkown database xxx_development'

So it's back to thinking that we are  in the development environment.  I have  checked that the database.yml file shows the correct database name under the :production tag.  Also in environment.rb there  is  an ENV['RAILS_ENV'] ||= 'production' line.  The virtual host files  also have the correct RailsEnv set up.  Although I can't see how rake is affected by that.

I have  looked in the 'production.log' file but there  is no info regarding the migrate error in there.  So what am I doing wrong now?  All help gratefully received with thanks.

Re: Deploying app to production environment

I've done  some  more testing  and the interesting thing is that the app still continues to work so it is  picking up the production environment correctly.  Which means that only rake is getting the environment wrong.  Does anybody know where rake  gets it's environment info from?  The actual migration files don't hold any database names just table and column names  etc.

Re: Deploying app to production environment

rake db:migrate RAILS_ENV=production

Last edited by andain (2010-09-22 09:02:01)

Re: Deploying app to production environment

I've been using andain's suggestion to get by.  However just to increase my knowledge, does anyone  know where rake picks up it's  environment from? I hate not knowing wink!

Thanks