Ruby on Rails Tools

This is a summary of some of the tools I’m using with Rails, I’m putting together a list to try and get a few more people trying it out. I’m hoping a few people will try out some of the tools and ask questions in the Ruby forum.

Ruby / Rails Tools
Rails is quite simply the best way to build web applications, I’m not lying to you.
It is a collection of best practices, agile workflow and tooling to make web development fun and productive again. I Really Like Rails.

OS
Nearly all Rails developers use Mac OSX, it’s easiest to follow along and receive help if you’re using the same.
If you only have access to windows it’s probably worth downloading and running Ubuntu cause you really need a unix shell.
But if you’re intent on using windows check out http://railsinstaller.org/

Now that we all have our shiny dev machines encased in aluminum…

Read the official rails guides, they contain everything you need to know.
I can’t stress how ridiculously good these docs are, they will answer all of your questions.

Installation and Tools
On a clean install of OSX
Software Update… from the apple menu
install XCode from the app store
Install Command Line Tools for Xcode from http://developer.apple.com/downloads

zsh
Learn to love the command line
https://github.com/robbyrussell/oh-my-zsh

Rubygems

gem update --system
gem install bundler
gem install rails
gem install heroku

If it says “command not found: gem” download and install here
http://rubygems.org/pages/download

Github
If you don’t have a github account yet create one
https://github.com/signup/free

Heroku
If you don’t have a heroku account yet create one
https://api.heroku.com/signup

Git

git config --global user.name "<your name>"
git config --global user.email <your email>
git config --global color.ui true

If it says “command not found: git” download and install here
http://git-scm.com/book/en/Getting-Started-Installing-Git

Generate SSH keys to authenticate your machine with your github account
https://help.github.com/articles/generating-ssh-keys

Homebrew
https://github.com/mxcl/homebrew/wiki/Installation

Homebrew packages
Run “brew install <package>” and read all of the output, if something hasn’t installed correctly it will tell you how to fix it.
You can run “brew doctor” to see if something’s not quite right.

brew install rbenv
brew install postgresql
brew install git-flow
brew install imagemagick
brew install gs

Textmate
Not free, but a fast, lean, beautiful text editor
http://macromates.com/

Pow
A Rack server for development
http://pow.cx/

Create a Rails app, put source in Github, deploy to Heroku
You can put your applications anywhere but “projects” in the home directory “~” is a common place, all other code repos you can clone to ~/code

mkdir ~/code
mkdir ~/projects
cd ~/projects

Create a new rails application called ‘barebones’ using postgresql

rails new barebones -d postgresql
cd barebones

Install all the gems in Gemfile

bundle install

Edit database config

mate config/database.yml

Paste this and save

development:
  adapter: postgresql
  database: barebones_development
test:
  adapter: postgresql
  database: barebones_test

Create the database

rake db:setup

Symlink to the pow directory so you can run it locally

cd ~/.pow
ln -s ~/projects/barebones

Init git and commit all files

git init
git add .
git commit -am 'first commit'

Add a ‘remote’ so you can push code to github

git remote add origin git@github.com:<your-name>/barebones.git
git push origin master

Create a heroku app and deploy to it

heroku create
git add remote heroku <heroku-git-address e.g. git@heroku.com:warm-ocean-5452.git>
git push heroku master

We now how have:
A new rails app with db running at [indent][noparse]http://barebones.dev/[/noparse] on the Pow server for development[/indent]
Our code in a github repo at [indent][noparse]https://github.com/&lt;your-name&gt;/barebones[/noparse][/indent]
A Live environment hosted on Heroku at an address like [indent][noparse]http://warm-ocean-5452.herokuapp.com/[/noparse][/indent]

Check out http://guides.rubyonrails.org/ to learn more.

Pre-compilers
SASS & Coffeescript are defaults in Rails so you’ll already have these in your Gemfile
Add HAML and Compass and ‘bundle install’ or ‘bi’ if you installed ohmyzsh

gem 'haml-rails'
gem 'compass-rails'

Haml compiles to HTML
Sass & Compass compile to CSS
Coffeescript compiles Javascript

I still occasionally butt heads with Coffeescript and Haml but for the most part I find them great and they require a lot less code.
Sass and Compass are absolute no brainers, if you’re not using them yet, do.

To use pre-compilers you just add extensions to your views, stylesheets or javascript files e.g.
edit.haml, application.js.coffee, application.css.scss

Testing with Cucumber, Capybara and RSpec
There’s great value in writing automated tests, refactor your code and ensure you haven’t broken anything.

group :test do
  gem 'rspec'
  gem 'rspec-rails'
  gem 'capybara'
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem 'selenium-webdriver'
  gem 'machinist'
  gem 'faker'
end

Git Flow
Intelligent branching patterns for git
https://github.com/nvie/gitflow/

Sphinx
A powerful search database similar to Lucene, Ferret or Solr
http://freelancing-god.github.com/ts/en/installing_sphinx.html

Babushka
Automate things e.g. provisioning servers, deployment tasks, building a dev environment
http://babushka.me/

Paperclip with imagemagick
Attach files / images to ActiveRecord models
https://github.com/thoughtbot/paperclip/

Ruby Toolbox
Search for gems and find which ones are active and popular
https://www.ruby-toolbox.com/

New Relic
Performance Monitoring for you app
https://rpm.newrelic.com/

If you have any questions about any of those tools or ran into problems setting up your environment ask away.

Hi Mark,

Thanks for the awesome write-up of tools for Rails. I went through this over the weekend and installed Rails and created a small project and worked through the syntax and handling. I quite liked it. It was relatively easy to transfer C#, Java and PHP knowledge to Rails. I don’t know if I will have time to explore this more in the ‘near’ future. But everything you laid out here is great to get started with it!

Regards,
Steve

Thanks Steve,

Yes, it’s pretty easy to get started with Rails if you’re familiar with other programming languages.
The biggest hurdle people have is needing to adopt the conventions and do things the Rails way, if you work within those conventions then it’s easy to work with.

Two years ago I really dug into ruby and rails but after getting a job at a PHP and C shop haven’t looked at since. I have always found it interesting and the syntax elegant. Will have to use your post as a stepping stone to getting back into in my down time. I mean rails is the MVC framework all other domain based MVCs *try to replicate. So I think that talks worlds.

I had originally looked at Heroku quite a long time ago and thought it was an inferior choice over ‘real hosting’.
But recently, I had a project where my host was causing a lot of struggles with Capistrano (SSH key stuff) and I turned [back] to Heroku. It has matured quite a bit and I have now become a big fan. With their toolkit installed (on my MackBook) deploying a Rails application is as easy as ‘git push heroku’ !

Secondly, I wanted to add to this list (at your discretion, @markbrown4; ) RubyMine by JetBrains. I viewed their videos and was impressed enough to download a trial.
After using it I discovered so many awesome features (I think the videos do not do it justice) that I felt compelled to purchase a license.
It is THE DEFINITIVE Integrated Development Environment (IDE) for Rails. It also supports other, similar, technologies like RubyMotion. They have a very flexible license too.

Feel free to add to the list, however I always enjoy quoting this whenever IDE’s are discussed.

Where’s my IDE?
If you’re coming to Ruby and Rails from languages such as C# and Java, you may be wondering about IDEs. After all, we all know that it’s impossible to code modern applications without at least 100MB of IDE supporting our every keystroke. For you enlightened ones, here’s the point in the book where we recommend you sit down - ideally propped up on each side by a pile of framework references and 1,000-page Made Easy books. There are no fully-fledged IDEs for Ruby or Rails (although some environments come close). Instead, most Rails developers use plain old editors. And it turns out that this isn’t as much of a problem as you might think. With other, less expressive languages, programmers rely on IDEs to do much of the grunt work for them: IDEs do code generation, assist with navigation, and compile incre- mentally to give early warning of errors. With Ruby, however, much of this support just isn’t necessary. Editors such as TextMate give you 90 percent of what you’d get from an IDE but are far lighter weight. Just about the only useful IDE facility that’s missing is refactoring sup- port. for and edit previous commands, and how to complete the names of files and commands as you type. So-called tab completion is standard on Unix shells such as Bash and zsh. It allows you to type the first few characters of a filename, hit Tab , and have the shell look for and complete the name based on matching files.

Most Rails developers I know use SublimeText, Textmate or Vim which are all plain but flexible text editors.

I agree completely and have been a fan of SublimeText (for Rails development) for quite a while. It seems that Rails is attractive to the more ‘hard core’ CLI-driven geeks.

I love that paragraph. From whence does that come?

Agile Web Development with Rails.

Im a Rails developer in Linux environment and I use Aptana, it works great, I have use SublimeText 2 its a great tool