Ubuntu Rails Blog

Guiding Penguins in a world of Apples

Hello Rails World!

What’s the deal with Rails developers and the Apple Mac?

  • Build quality is good and its a fashionable tech accessory
  • Single platform across a team of developers makes for an easier life and Mac is the obvious choice
  • 37 Signals use them! They even made a cheezy video about it!!
  • Textmate, the standard Rails text editor in many ways is Mac only software

I’m not trying to dissuade anyone from using a Mac for Rails development – I like having a choice.

Ruby on Rails is not, last time I checked anyway, a Mac specific programming language / web framework.

Having just moved to the latest Ubuntu (12.04 LTS) as a platform for my RoR projects i’m finding it a comparably slick alternative to the OS X monopoly.

Rails Editor Choices in Linux

Without Textmate the defacto ‘modern’ Rails editor – who by the way insist there will only ever be a Mac version there is still plenty of choice out there.

Some may persuade you to Emacs other Gedit with the Rails plugins. What I did was go through many of the editors looking for a Textmate alternative and to cut a long story short ended up with Sublime Text 2.

Sublime Text 2 is not perfect but does have a similar feature set to Textmate and is super fast, the opposite of the Java based offerings I tried (Ajunta and Ruby Mine).

Add the webupd8 maintained repo and install
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text-2-dev
sudo apt-get install sublime-text-2-beta@

Railscasts theme
https://raw.github.com/ryanb/textmate-themes/master/railscasts.tmTheme Copy to .config/sublime-text-2/Packages/Color Scheme - Default Preferences > Color Scheme > railscasts

Sublime Text 2 Options
View > Hide minimap

Package Manager
View > Show console

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'

Install Packages
Preferences > Package Control > Package Control:Install Package ERB Insert and Toggle Commands Rails Related Files RubyTest Rspec Haml Sass Coffeescript

Preferences > Settings - User { "color_scheme": "Packages/Color Scheme - Default/railscasts.tmTheme", "font_face": "Droid Sans Mono", "font_size": 12, "scroll_past_end": false, "detect_indentation": false, "tab_size": 2, "translate_tabs_to_spaces": true, "trim_trailing_white_space_on_save": true, "word_wrap": true }


Open file in browser

Tools > New plugin…

  1. OpenBrowser.py
    import sublime, sublime_plugin
    import webbrowser

class OpenBrowserCommand(sublime_plugin.TextCommand):
def run(self,edit):
url = self.view.file_name()

Tools > Command Palette > “User Key bindings”
{ “keys”: [“ctrl+shift+b”], “command”: “open_browser” },
{ “keys”: [“ctrl+shift+.”], “command”: “erb” }

  • Posted on June 16, 2012