Note this is for Rails 2.x, which is quickly being overwhelmed by 3.0 doc on the web.
Migration Examples
./script/generate migration add_posts ./script/generate migration add_user_id_to_posts user_id:string
Rake commands:
- rake gems:install – update to the latest gems
- rake db:migrate – update db tables
- ruby script/server – run the dev environment
MySQL build errors
when running “cap [deployfile] ec2onrails:setup” use aptitude install libmysqlclient15-dev
EC2 on Rails
There are two machines:
Controller: Where you are running the capistrano commands
Server: The EC2 instance where the app will be running (potentially multiple)
- Controller: sudo gem install ec2onrails
- Controller: suso gem install capistrano
- Controller: svn checkout https://rsportzcvs.svn.cvsdude.com/Swooshdot/trunk
- Start Server instance(s) using ec2onrails AMI
- Controller: Edit config/deploy.rb
- Set scm_username/password
- set role :web,app,db,memcache to Server(s) public DNS name
- point ssh_options[:keys] to your ssh private key
- Controller: cap ec2onrails:get_public_key_from_server
- If this doesn’t work, you probably don’t have the right private key
- Controller: cap ec2onrails:setup
- Controller: cap ec2onrails:db:set_root_password
- Controller: cap deploy:cold
- Server:
cd /mnt/app/shared s3cmd sync s3://rsportz-shared/ .
Assuming you previously ran “s3cmd –configure” and answered all the questions in a sane manner.
Note you only need to do steps 1, 2 and 6 once on your staging server (if all your instances share the same key), then repeat the following for each new instance
For a simple server test, do the following:
$ RAILS_ENV=development ruby script/server webrick
Evil 1.8.7-p248 hack
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz
tar xvfz ruby-1.8.7-p249.tar.gz
cd ruby-1.8.7-p249/ext/openssl/
ruby extconf.rb
make sudo make install
sudo cp -R /usr/local/lib/ruby/site_ruby/1.8/openssl* /usr/lib/ruby/1.8/
To check if you got it right:
# irb
irb(main):001:0> require ‘openssl’
=> true
irb(main):002:0> quit