Setting up Sublime Text 3 for Rails Development

When I started programming, IDEs were the norm. I spent much of my time using tools like Microsoft Visual Studio and got very used to features like Autocomplete. However, that also meant I needed to have access to MSDN which for a young professional was very expensive if you wanted to develop on your own dime and time. IDEs also tend to be very prescriptive and require a lot of overhead in order to run the tools themselves. Almost a decade later, I was introduced to the world of developing using open source languages, tools and frameworks and I quickly fell in love with it. One of the biggest changes though was to not use an IDE. While most of my hard core friends use tools like VIM or VI, I use Sublime Text 3 for my Rails development which is a bit of a cop out but it’s still a pretty amazing tool. I decided to document my experience on my setup of Sublime Text 3 for my personal Rails development. Hopefully others will find this equally useful.

Most of influence of setting up Rails for Sublime Text comes from Michael Hartl’s site.

  1. Install Sublime Text
  2. Set up Sublime to run from the command line
    Create a symbolic link for the sublime executable

    ln -s /Applications/Sublime /usr/local/bin/sublime

    Reload your profile

    source ~/.bash_profile
  3. Install Package Control
    From the Sublime console, insert this snippet of Python code

    import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( '' + pf.replace(' ','%20')).read())
  4. Go to the Package Controller
  5. Install Rails Tutorial snippets from the command line
     cd ~/Library/Application Support/Sublime Text 3/Packages/
    git clone RailsTutorial
  6. Set up syntax specific settings for Ruby
    • Go to a file with a .rb extension
    • Go to Preferences –> Settings More –> Syntax Specific – User
    • Paste the following into the file
      "tab_size": 2, "translate_tabs_to_spaces": true
  7. Set up syntax specific settings for Ruby HTML files
    1. Go to a file with an .erb extension
    2. And follow the previous steps

For other tips about Rails development type tricks, checkout my Rails cheatsheet or my OS X cheatsheet

Installing Ruby on Rails on OSx

I got myself a Macbook Air today to primarily be a development machine. For those of you who are looking for a shortcut, check out RailsInstaller that does a quick job as well. Personally, I just wanted to give a shot of installing Rails from scratch because it’s a good way of really understanding your system and the appropriate pre-requisites to run Rails. Also, it allows you to specify what version of Rails and ruby you want installed on your system.

I assume that you already have Homebrew installed on your system.

  1. Install RVM
    run curl -L | bash
  2. Re-load your environment
    source ~/.rvm/scripts/rvm
  3. Setup additional pre-requisites
    brew install libyaml
    brew install openssl
  4. Install ruby 2.0.0 and set it as the default version
    rvm install 2.0.0 –with-openssl-dir=$HOME/.rvm/usr
    rvm –default use ruby-2.0.0-p247
  5. Install Rails and Bundler
    gem install rails –version=3.2.14
    gem install bundler
  6. Install SQLite which is good quick database for development purposes
    brew install sqlite3