27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50 CHAPTER 3 Developing a real Rails application<br />

Listing 3.3 Terminal<br />

Counting objects: 73, done.<br />

Compressing objects: 100% (58/58), done.<br />

Writing objects: 100% (73/73), 86.50 KiB, done.<br />

Total 73 (delta 2), reused 0 (delta 0)<br />

To git@github.com:rails3book/ticketee.git<br />

* [new branch] master -> master<br />

Branch master set up to track remote branch master from origin.<br />

The second to last line in this output indicates that your push to GitHub succeeded<br />

because it shows that a new branch called master was created on GitHub. Next, you<br />

must set up your application to use RSpec and Cucumber.<br />

3.1.3 The Gemfile and generators<br />

The Gemfile is used for tracking which gems are used in your application. The Bundler<br />

gem is responsible for everything to do with this file; it’s the Bundler’s job to ensure that<br />

all the gems are installed when your application is initialized. Let’s look at the following<br />

listing to see how this looks inside (commented lines are removed for simplicity).<br />

Listing 3.4 Gemfile<br />

source 'http://rubygems.org'<br />

gem 'rails', '3.1.0'<br />

gem 'sqlite3'<br />

group :assets do<br />

gem 'sass-rails', " ~> 3.1.0"<br />

gem 'coffee-rails', "~> 3.1.0"<br />

gem 'uglifier'<br />

end<br />

gem 'jquery-rails'<br />

group :test do<br />

# Pretty printed test output<br />

gem 'turn', :require => false<br />

end<br />

In this file, Rails sets a source to be http://rubygems.org (the canonical repository for<br />

Ruby gems). All gems you specify for your application are gathered from the source.<br />

Next, it tells Bundler it requires version 3.1.0.beta of the rails gem. Bundler<br />

inspects the dependencies of the requested gem as well as all gem dependencies of<br />

those dependencies (and so on), then does what it needs to do to make them available<br />

to your application.<br />

This file also requires the sqlite3 gem, which is used for interacting with SQLite3<br />

databases, the default when working with Rails. If you were to use another database<br />

system, you would need to take out this line and replace it with the relevant gem, such<br />

as mysql2 for MySQL or pg for PostgreSQL.<br />

The assets group inside the Gemfile contains two gems called sass-rails and<br />

coffee-rails. The sass-rails gem provides a bridge into the sass gem, which

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!