RoR setup instructions: I guess you already have XCode on your machine.
In general: avoid sudo where you can, with this setup you can install and run everything without sudo
http://mxcl.github.com/homebrew/
here is a list of the packages on my machine
~$ brew list
qt ack cmake curl git imagemagick jpeg libmemcached libxml2 libyaml memcached pcre pkg-config redis sqlite bash-completion colordiff ghostscript graphviz jasper libevent libtiff libxslt little-cms mysql openssl pidof readline scons swig wget
sudo apt-get install libqt4-dev libqtwebkit-dev imagemagick
http://beginrescueend.com/rvm/install/
RVM is pretty cool and simple, as long as you don't have trouble with readline support or ssl support, if ruby/rails complains about openssl missing or you can't type 'C' into the rails console, let me know, it can be fixed.
installation is actually a one-liner
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
to install the ruby version just say:
rvm install 1.9.3
# unless you have XCode 4.2 then it's
rvm install 1.9.3 --with-gcc=clang
This creates a gem set on first use and sets the gem set whenever you enter the folder. Why gemsets? They keep the dependencies apart between projects. Each project can have it's own. cd into the folder to activate the gemset
rvm_gemset_create_on_use_flag=1
# switch to default ruby version when exiting directory
rvm_project_rvmrc_default=1
# use ruby 1.9.3 with a specific gem set
rvm ruby-1.9.3-p0@v2
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
and here are a couple of my .bashrc aliases if you like
alias gemkill='gem list | cut "rake" | cut -d" " -f1 | xargs gem uninstall -aIx'
alias gti="git"
alias log="git log --oneline --decorate"
alias e="subl ."
alias b="bundle exec"
alias g="bundle exec guard -c"
alias pryy="pry -r ./config/environment"
alias pryr="pry -r ./config/environment"
These gems are available across all gemsets
rvm gemset use global
gem install bundler pry awesome_print
rvm gemset use v2
Pry is a really great ruby console(irb) replacement, that allows you to do lots of cool debug stuff
.pryrc in your home dir
# switch default editor for pry to sublime text
Pry.config.editor = "sublime"
# format prompt to be <Rails version>@<ruby version>(<object>)>
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version} @ " if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj})>\e[0m"
end
# load Rails Console helpers like reload
if defined?(Rails) && Rails.env
require 'rails/console/app'
require 'rails/console/helpers'
extend Rails::ConsoleMethods
puts 'Rails Console Helpers loaded'
end
# use awesome print for all objects in pry
begin
require 'awesome_print'
Pry.config.print = proc { |output, value| output.puts "=> #{ap value}" }
rescue
puts "=> Unable to load awesome_print, please type 'gem install awesome_print' or 'sudo gem install awesome_print'."
end
# My pry is polite
Pry.config.hooks.add_hook :after_session, :say_bye do
puts "bye-bye" if Pry.active_sessions == 1
end
cs=Pry::CommandSet.new do
import Pry::Commands
command "lm","Alias for ls -m" do |args|
run "ls", "-m #{args}"
end
command "lM", "Alias for ls -M" do |args|
run "ls", "-M #{args}"
end
end
Pry.config.commands = cs
Bundler is the Rails package manager, it computes all the different versions dependencies in your project and finds a set that actually will work together. So you don't have to worry much about dependency management
#check that you are in the v2 gemset
rvm gemset list
bundle install
put this into app/db
mysql: &mysql
adapter: mysql2
encoding: utf8
reconnect: false
pool: 5
socket: /tmp/mysql.sock
development:
<<: *mysql
database: carrier_pigeon_v2_development
test: &test
<<: *mysql
database: carrier_pigeon_v2_test
production:
<<: *mysql
database: carrier_pigeon_v2_production
rake db:create
rake db:migrate
rake db:seed
Check if rails runs and all the tests pass
# this starts the rails (pry) console
rails c
# this runs the whole test suite, if this runs all green, we're good to go
rake spec