How to set up The Wonderful World of Ruby and Rails™ on OS X.
Supported: 10.6 Snow Leopard and 10.7 Lion. Sorry, no 10.5 Leopard and so far not tested on 10.8 Mountain Lion.
-
Set up a Backup with Time Machine!!11! Yes, that might include going to the store and buying a harddrive. Do not continue without having a backup!
-
If you've never used the terminal before, find out how to write a tilde (
~
) and do 5 minutes of shell basics. -
You should have tried Ruby. It's also recommended to try Git.
-
Stack Overflow is the better Google for coding matters while DuckDuckGo doesn't track you, has the nicer UI and some nifty goodies. Tattoo "search the interwebs!!11!" on the back of your hands. Whenever you read a word you do not understand, look on the back of your hands!
-
Install 1password and its browser extensions.
-
Check out Markdown and install Mou. Also install iTerm2 and Sublime Text.
-
Update to latest version of 10.6 Snow Leopard or 10.7 Lion.
-
You will find this at the Mac App Store. It's huge. This will take some time to download.
We also need the Command Line Tools for Xcode from within Xcode's Download preferences:
-
Make hidden files visible by pasting this into the terminal
$ defaults write com.apple.Finder AppleShowAllFiles YES
and restart the finder:
Then activate keyboard control for system dialogues:
-
is currently installed by doing:
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
after which
$ brew doctor
should happily announce that:
Your system is raring to brew.
Homebrew installs packages into
/usr/local/bin
, so we need to edit the file/etc/paths
to tell the system to look there first. Open/etc/paths
with Sublime Text. On a fresh Lion install that file should look something like this:/usr/bin /bin /usr/sbin /sbin /usr/local/bin
That last line
/usr/local/bin
needs to go to the top, so the file looks like this:/usr/local/bin /usr/bin /bin /usr/sbin /sbin
Save the file (will ask for your admin password) and restart the terminal.
-
We want to uninstall the git version that came with OS X and install an up-to-do version with homebrew:
$ which git
will output (on Lion at least)
/usr/bin/git
so we need to do
$ sudo rm -rf /usr/bin/git
to remove the old git and
$ brew install git
to install the new version. Now you can do
$ git --version
and
$ which git
-
$ brew install rbenv $ brew install ruby-build
We now need to edit the bash profile which doesn't exist on a fresh system. Do:
$ touch ~/.bash_profile
paste the line
eval "$(rbenv init -)"
into it and restart the terminal.
$ rbenv versions
shows nothing. We need to install a Ruby into rbenv by doing:
$ rbenv install 1.9.3-p194
This may take a while. Then do:
$ rbenv versions
which should output:
1.9.3-p194
Do
$ rbenv global 1.9.3-p194 $ rbenv versions $ rbenv version
-
Do:
$ gem install bundler
and restart the terminal. Note: if you get a permission error, you must do
sudo gem install bundler
–– same with other gems. -
$ gem install heroku
and restart the terminal. Then do:
$ heroku login
-
create a folder called
my_awesome_blog
in yourprojects
-folder -
log into github
-
fork and clone it into
~/projects/my_awesome_blog
-
install needed gems with bundler:
$ cd ~/projects/my_awesome_blog $ bundle install
-
$ heroku create
-
push your app online:
$ git push heroku master
-
Open the URL in your browser.
Do you see your new blog? Congratulations #1!
You don't have to push every change to Heroku to check it out. You can run a server on your very own machine.
-
Install thin:
$ gem install thin
and restart the terminal.
-
go to your blog directory and start the server:
$ cd ~/projects/my_awesome_blog $ thin start
-
open
0.0.0.0:3000
in your webbrowser
Do you see your local copy of the blog? Congratulations #2!
- Open the file
~/projects/my_awesome_blog/templates/layout.rhtml
in your code editor - Find line 23
- Change "My Blog" to "Hello World"
- Save the file
- Check it out by updating your browser!
Do you see your changes? Congratulations #3!
Have a look at the terminal window where you started thin. You can see the requests your local server is answering.
Now commit and push:
$ git commit -am "Effyeah, my first commit evah!"
$ git push heroku master
$ git push origin master
Do you see your changes on your deployed version of the blog and on your github repo? Congratulations #4!
…get a beer and pat yourself on the back for next couple hours.
- https://github.com/nathos/sass-textmate-bundle
- sass user variables: tabs, word wrap, file types
- Look up
.gemrc
and why it could make sense to add the linegem: --no-rdoc --no-ri
to it - bash_profile + links profile vs rc etc…
- Learn HAML and SASS
- Learn more shell
- Learn more Ruby
- Start blogging (you now have your own blog, you know?)
- Take a long walk (always helps)
- Do lots of reading about the tools you are using
- Find your local Ruby usergroup or Railsgirls group. If there is none, start one!
- Find the nearest BarCamp on Ruby and Rails. If there is none, start one!
- Check out out how to map your new blog to your own domain
- Drink more water
- Make a branch of your blog, change the design, later merge it to your master branch
- Try to get a rails app running
- Try Pow
- Learn some JavaScript –– or if you know JavaScript, check out CoffeeScript
- get more good advice…
- …and give feedback.
A very special thanks to 5v3n. This doc originated as part of documentation for The Ratpack Workshop.
Also thanks to the Hamburg Ruby Community, especially blindgaenger and the mindmatters crew.
HT to Ben for the hint on enabling keybard control for all system dialogues.
- Git, Git, Git and Git. Really, you can never know enough about Git, Git, Git and Git.
- How do RVM and RBENV actually work?
(more coming. maybe.)