Deploying Ruby on Rails 3.1 to WebFaction
Wednesday 21 September 2011
WebFaction has a new Rail 3.1 installer out. I nevertheless hit a few obstacles in setting up a new app.
Ruby EE vs Ruby 1.9.2 Issues
First off, the installer is using the Ruby Enterprise Edition rather than 1.9.2 which I hadn’t planned on, so all of the new hash syntax I was using did not work out. So – you may want to install Ruby 1.9.2 for starters. I was able to do that relatively painlessly by removing the existing install files, then installing into the same directory (~/webapps/yourapp)
Asset Pipeline Issues
Secondly, the asset pipeline was a bit of a problem - the capistrano task rake assets:precompile never finishes and caused me to receive a memory over limit warning message. After some back and forth with a not particularly tech support person it seemed that you can’t precompile on the production server – at least not with the standard shared hosting plan. I ended up finding a capistrano task that allows local compilation:
Path Variables
You'll also want to add some path variables to .bash_profile and .bashrc:
export PATH=$PWD/bin:$PATH
export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
deploy.rb
desc "deploy the precompiled assets"
task :deploy_assets, :except => { :no_release => true } do
run_locally("rake assets:clean && rake assets:precompile")
upload("public/assets", "#{release_path}/public/assets", :via =>
:scp, :recursive => true)
end
after 'deploy:update_code', 'deploy_assets'
Gemfile
One snag I have still not figured out is that cucumber-rails is causing a “the spawn server has exited unexpectedly” warning message, so I am keeping the entire test portion of the Gemfile commented out and then uncommenting each time I run the test suite, a pain in the butt, but it works.
=begin
group :test, :development do
gem "rspec-rails"
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'capybara'
end
=end
Other than that, things went pretty smoothly and so far the app has been running well.
