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