views:

95

answers:

3

I've inherited a rails site that I need to deploy (quickly!) to our webhost, which is a standard *nix shared server that uses FastCGI for rails apps. I've worked with rails sites on multiple occasions in the past but wouldn't consider myself an expert by any stretch.

This particular app was developed using capistrano, with which I've got no experience, and everything I've read leads me to believe that to deploy the app "properly" would require my setting up an external svn account, among other things, which aren't feasible given our time frame and hosting situation.

My question is: what is the best way to quickly get this application up and running without using capistrano? I received, along with the site files, a .sql dump that I've already imported, and I've configured config/database.yml to reflect the correct production db settings. Right now, running ruby script/console production yields the following error message:

/home/user1/ruby/gems/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in `load_missing_constant':NameError: uninitialized constant ApplicationController

Thanks for your consideration!

+1  A: 

All capistrano requires is a deploy.rb and a Capfile, this is not what is causing your error. From the looks of it it seems that the problem is that you're using a gem rails version which is incompatible with your app, do you know which version it was developed with? If so you should try vendoring your rails directory to the right version.

For deployment, if you're using FastCGI you can just upload the files to the host and set the appropriate permissions and you should be good to go. Going forward you might want to look at upgrading to a newer version of rails, using capistrano and changing your environment to use apache passenger.

I hope this helps.

jonnii
jonnii, thanks for the response. What do you mean by vendoring my rails directory?I'm definitely aware that this isn't the best-practices approach, and in the future I'm going to be using git, capistrano, and passenger in rails dev/deployment, but I need to get this site live by the end of the day.
justinbach
A: 

The problem you're running into appears to be a mismatch of your installed version and the version that the app is expecting. Look in config/environment.rb, Toward the top you'll see something that looks like:

RAILS_GEM_VERSION = '2.3.4'

You need to make sure that the version of rails installed on your machine matches whatever version is declared in that file. You can do that by running:

sudo gem install -v=X.X.X rails

where X.X.X matches what was in your environment.rb.

Jonnii is suggesting you "freeze" your rails by including all the rails code into your project directly, (which can be done by running rake rails:freeze:gems AFTER you have followed the above steps and gotten the correct gems installed in the first place.) Once you've frozen rails, then you no longer need to have the rails gems installed on your webserver machine.

Good luck!

codenoise
+1  A: 

As the others already stated, you are probably using the incorrect version.

Rails switched from app_controller to application_controller (or something like that) in version 2.1 or 2.2.

There is a rake task that you should be able to run in that case:

rake rails:update:application_controller

It might help you.

As for the capistrano. In your deploy.rb you can add the parameter :deploy_via :

set :deploy_via, :copy
set :scm, :none

And it should use the copy you are having in your working directory to deploy with (no need for subversion or any other version control)

Copy usually fetches the code from a repository locally and then uploads it to the server, but also setting the :scm to none it should ignore that and just (hopefully) use your working copy instead.

Jimmy Stenke