-
Notifications
You must be signed in to change notification settings - Fork 3
rails 3 2 example gemfile
Last updated 21 February 2013
Here are example Gemfiles for typical applications built with Rails 3.2.
See Installing Rails 3.2 for detailed instructions and advice.
John Mcdowall offers some useful advice about Gemfile Best Practices.
A Rails 3.2.12 application includes the following Gemfile when created with the rails new
command:
source 'https://rubygems.org' gem 'rails', '3.2.12' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails'
Check for the newest versions of these gems:
Here are gems that are often added to a new Rails application.
Since Rails 3.1, a JavaScript runtime has been needed for development on Linux Ubuntu. It is not needed for Mac OS X or Windows.
For development on Linux Ubuntu, it’s best to install the Node.js server-side JavaScript environment:
sudo apt-get install nodejs
and set it in your $PATH
.
If you don’t install Node.js, you’ll need to add this to the Gemfile for each Rails application you build:
gem 'therubyracer', '>= 0.9.9'
Check for the newest version of therubyracer.
Heroku provides low cost, easily configured Rails application hosting. For your convenience, see Tutorial: Rails 3.2 with Ruby 1.9.3 on Heroku.
Heroku uses PostgreSQL as its default database. If you don’t want to install PostgreSQL locally, you can set your Gemfile to use SQLite locally and PostgreSQL in production (see the article for pros and cons). You’ll likely use the Thin web server for a production app though you may wish to use the default Webrick locally.
Run bundle install --without production
to update your gems. Here’s the Gemfile you’d use:
source 'https://rubygems.org' gem 'rails', '3.2.12' # for deployment on Heroku gem "heroku" group :development, :test do gem 'sqlite3' end group :production do gem 'pg' gem 'thin' end # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails'
RSpec is a popular alternative to the Test::Unit testing framework. Cucumber is used with RSpec for Behaviour Driven Development.
Several gems are commonly used with RSpec and Cucumber. Factory_girl is a fixtures library used to create objects needed for testing. Capybara allows testing of web pages by simulating HTTP requests as if someone was using a browser. Database_cleaner is used to initialize a database to a clean state during tests. Launchy is used to launch a web browser to display the state of a web page during testing (primarily for debugging tests).
Here’s a Gemfile configured for RSpec and Cucumber:
source 'https://rubygems.org' gem 'rails', '3.2.12' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' group :development, :test do gem "rspec-rails", ">= 2.8.1" end group :test do gem "factory_girl_rails", ">= 1.6.0" gem "cucumber-rails", ">= 1.2.1" gem "capybara", ">= 1.1.2" gem "database_cleaner" gem "launchy" end
Check for the newest versions of these gems:
Here are Gemfiles for the example apps in the Rails Apps repository.
A few of the example apps use the Mongoid gem for access to a MongoDB datastore.
A few of the example apps use Devise for authentication.
One of the example apps uses OmniAuth for authentication.
The example apps have been tested with the indicated versions.
For the RailsApps example apps built with Rails 3.2, use the following gems and specify versions optimistically (using the >=
operator).
The RailsApps example apps have been tested with this configuration:
- Ruby 1.9.3
- RubyGems 1.8.24
- Rails 3.2.12
- Rake 10.0
Note: The RailsApps examples are generated with application templates created by the Rails Apps Composer Gem. For that reason, groups such as :development
or :test
are specified inline. You can reformat the Gemfiles to organize groups in an eye-pleasing block style (as presented in the Gemfiles shown above). The functionality is the same.
source 'https://rubygems.org' gem 'rails', '3.2.12' gem 'sqlite3' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem "rspec-rails", ">= 2.8.1", :group => [:development, :test] gem "factory_girl_rails", ">= 1.7.0", :group => :test gem "email_spec", ">= 1.2.1", :group => :test gem "cucumber-rails", ">= 1.3.0", :group => :test gem "capybara", ">= 1.1.2", :group => :test gem "database_cleaner", ">= 0.7.1", :group => :test gem "launchy", ">= 2.0.5", :group => :test gem "devise", ">= 2.0.4"
source 'https://rubygems.org' gem 'rails', '3.2.12' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem "rspec-rails", ">= 2.8.1", :group => [:development, :test] gem "database_cleaner", ">= 0.7.1", :group => :test gem "mongoid-rspec", ">= 1.4.4", :group => :test gem "factory_girl_rails", ">= 1.6.0", :group => :test gem "cucumber-rails", ">= 1.2.1", :group => :test gem "capybara", ">= 1.1.2", :group => :test gem "launchy", ">= 2.0.5", :group => :test gem "bson_ext", ">= 1.3.1" gem "mongoid", ">= 2.4.3" gem "devise", ">= 2.0.0"
source 'https://rubygems.org' gem 'rails', '3.2.12' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem "rspec-rails", ">= 2.8.1", :group => [:development, :test] gem "database_cleaner", ">= 0.7.1", :group => :test gem "mongoid-rspec", ">= 1.4.4", :group => :test gem "factory_girl_rails", ">= 1.6.0", :group => :test gem "cucumber-rails", ">= 1.2.1", :group => :test gem "capybara", ">= 1.1.2", :group => :test gem "launchy", ">= 2.0.5", :group => :test gem "bson_ext", ">= 1.3.1" gem "mongoid", ">= 2.4.3" gem "omniauth", ">= 1.0.2" gem "omniauth-twitter"
source 'https://rubygems.org' gem 'rails', '3.2.12' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem "haml", ">= 3.1.4" gem "haml-rails", ">= 0.3.4", :group => :development gem "rspec-rails", ">= 2.8.1", :group => [:development, :test] gem "database_cleaner", ">= 0.7.1", :group => :test gem "mongoid-rspec", ">= 1.4.4", :group => :test gem "factory_girl_rails", ">= 1.6.0", :group => :test gem "cucumber-rails", ">= 1.2.1", :group => :test gem "capybara", ">= 1.1.2", :group => :test gem "launchy", ">= 2.0.5", :group => :test gem "bson_ext", ">= 1.3.1" gem "mongoid", ">= 2.4.3" gem "devise", ">= 2.0.0"