Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

306 lines (296 sloc) 22.684 kB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Read This Before Installing Rails 3.1 &#183; RailsApps</title>
<link href="https://plus.google.com/u/0/b/117374718581973393536/117374718581973393536/posts/" rel="publisher" />
<link rel="stylesheet" href="http://railsapps.github.com/css/bootstrap.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://railsapps.github.com/css/screen.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://railsapps.github.com/css/gollum.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://railsapps.github.com/css/site.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://railsapps.github.com/css/syntax.css" type="text/css" charset="utf-8" />
<script src="http://code.jquery.com/jquery-1.6.min.js" type="text/javascript"></script>
<script src="http://railsapps.github.com/javascript/jquery.text_selection-1.0.0.min.js" type="text/javascript"></script>
<script src="http://railsapps.github.com/javascript/jquery.previewable_comment_form.js" type="text/javascript"></script>
<script src="http://railsapps.github.com/javascript/jquery.tabs.js" type="text/javascript"></script>
<script src="http://railsapps.github.com/javascript/gollum.js" type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-5109366-14']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a href="http://railsapps.github.com/" class="brand">RailsApps Project</a>
<ul class="pull-right nav">
<li><a href="http://blog.railsapps.org/" class="twitter">Blog</a></li>
<li><a href="http://twitter.com/rails_apps" class="twitter">Twitter</a></li>
<li><a href="https://plus.google.com/117374718581973393536" class="google">Google +</a></li>
<li><a href="https://github.com/RailsApps" class="github">GitHub Repository</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="content wikistyle gollum textile">
<h1>Read This Before Installing Rails 3.1</h1>
<h4>by Daniel Kehoe</h4>
<p><em>Last updated 24 January 2012</em></p>
<h2>See a New Article for Rails 3.2!</h2>
<p>You’ve found an article that explains how to install Rails 3.1. But Rails 3.2 is the newest version!</p>
<p>You should follow this link to learn how to install Rails 3.2:</p>
<ul>
<li><a href="http://railsapps.github.com/installing-rails.html">Installing Rails 3.2</a></li>
</ul><p>It offers detailed (and current) instructions on how to install the latest release of Rails with advice and troubleshooting tips.</p>
<p><a href="http://www.twitter.com/rails_apps"><img src="http://twitter-badges.s3.amazonaws.com/t_logo-a.png" title="Follow on Twitter" alt="Follow on Twitter"></a> Follow <a href="http://twitter.com/rails_apps">@rails_apps</a> on Twitter for updates and timely Rails tips.</p>
<h2>What Was New</h2>
<p>You can read more about how the building blocks of the Rails platform work together by reading the article <a href="http://railsapps.github.com/managing-rails-versions-gems.html">Managing Rails Versions and Gems</a>. It explains the relationships among Ruby, RubyGems, Rails, Rake, Bundler, and gemfiles and offers some advice.</p>
<h4>Rails 3.1.3</h4>
<p>Rails 3.1.3 was released November 20, 2011, mainly to fix what broke in Rails 3.1.2 (see the <a href="http://weblog.rubyonrails.org/2011/11/20/rails-3-1-3-has-been-released">announcement</a>). Rails 3.1.2 was released November 17, 2011 to fix a number of small bugs and provide a security fix (detailed in the <a href="http://weblog.rubyonrails.org/2011/11/18/rails-3-1-2-has-been-released">announcement</a>).</p>
<h4>Rails 3.1</h4>
<p>Rails 3.1.0 was released August 31, 2011. Eight release candidates were released beginning May 21, 2011. Rails 3.1 introduced the <a href="http://www.youtube.com/watch?v=cGdCI2HhfAU">asset pipeline</a> which enables proper organization of <span class="caps">CSS</span> and JavaScript. Other features include <a href="http://railscasts.com/episodes/266-http-streaming"><span class="caps">HTTP</span> streaming</a>, default jQuery, reversible migrations, mountable engines, identity map, prepared statements, Rack::Cache on by default, forced <span class="caps">SSL</span>, role-based mass-assignment protection, has_secure_password, and custom serializers. See the <a href="http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate">Rails 3.1 release candidate announcement</a> for details. There’s a <a href="http://railscasts.com/episodes/265-rails-3-1-overview">Rails 3.1 Overview</a> from Ryan Bates and a <a href="https://gist.github.com/958283">changelog</a> for all the details. Yehuda Katz explains <a href="http://yehudakatz.com/2011/06/14/what-the-hell-is-happening-to-rails/">What’s Up With All These Changes in Rails?</a>. The best overview of Rails 3.1 is Michael Hartl’s <a href="http://ruby.railstutorial.org/chapters/rails-3-1#top">chapter on Rails 3.1</a> in his Ruby on Rails Tutorial book.</p>
<p><em>What You Need to Know:</em> The greatest impact for developers moving from Rails 3.0 to 3.1 is the new location for <span class="caps">CSS</span> and JavaScript files and changes to the application layout file. See the official <a href="http://guides.rubyonrails.org/asset_pipeline.html">Rails 3.1 Asset Pipeline guide</a> for details.</p>
<h4>Rake</h4>
<p>Rake is the build tool for Ruby. Rake version 0.9.2 was released on June 5, 2011 and followed by Rake version 0.9.2.2 on October 22, 2011. Rake 0.9.2.2 installs as part of Ruby 1.9.3.</p>
<p>Many gems depend on Rake and conflicting dependencies can be a problem, especially since the release of Rake version 0.9.0 (May 20, 2011). For an explanation, see <a href="http://blog.davidchelimsky.net/2011/05/28/rake-09-and-gem-version-constraints/">David Chelimsky’s blog post</a>. If needed, you can specify an earlier version of Rake in your gemfile to force the use of the Rake version specified in your gemfile. It’s good practice to use the command <code>bundle exec rake</code> instead of <code>rake</code> so you’ll use the version of Rake specified in your gemfile (or a dependency specified in the Gemfile.lock file) instead of the default version. For example, instead of <code>rake db:migrate</code>, run <code>bundle exec rake db:migrate</code>.</p>
<p><em>What You Need to Know:</em> Make sure you are using Rake 0.9.2.2 (or <a href="http://rubygems.org/gems/rake">newer</a>) with <code>gem update rake</code> before installing Rails 3.1. And use <code>bundle exec rake</code> instead of <code>rake</code>.</p>
<h4>RubyGems</h4>
<p>RubyGems is a package management framework for Ruby. RubyGems 1.8.11 was released October 3, 2011. RubyGems 1.8.10 installs as part of Ruby 1.9.3.</p>
<p>With version 1.8.0 (released May 4, 2011), the RubyGems system gem began a series of rapid updates. Releases between 1.8.0 and 1.8.5 generated “noisy” deprecation warnings but most installed gems continued to work. RubyGems 1.8.5 eliminated most of the deprecation warnings. If you think a gem may be failing because of an incompatibility with the newest RubyGems implementation, you can troubleshoot by rolling back to an earlier RubyGems system gem with <code>gem update --system 1.7.2</code> or <code>gem update --system 1.3.7</code>.</p>
<p><em>What You Need to Know:</em> Use <code>gem update --system</code> to upgrade to the <a href="https://rubygems.org/gems/rubygems-update">newest RubyGems system gem</a>.</p>
<h2>Update or Install?</h2>
<p><strong>Not recommended:</strong> You could run <code>gem update rails</code> for the newest version of Rails if you already have Rails installed.</p>
<p><strong>Recommended:</strong> You should use rvm, the <a href="http://rvm.beginrescueend.com/">Ruby Version Manager</a>, to create a new gemset for the new Rails version. Then you can switch between versions if necessary.</p>
<h2>Installing Rails 3.1.3</h2>
<p>Follow these instructions to set up Rails 3.1.3 as a platform for the <a href="http://railsapps.github.com/">Rails example apps</a> or any other apps you may build.</p>
<h4>Do You Ruby?</h4>
<p>Ruby should be installed on your computer. The version doesn’t matter; you’ll install Ruby 1.9.3 using rvm.</p>
<h4>Mac? Windows? Linux?</h4>
<p>On a Mac, you’ll need to <a href="http://itunes.apple.com/us/app/xcode/id448457090">install XCode</a> from the Mac App Store.</p>
<p>For Windows, start with <a href="http://railsinstaller.org/">RailsInstaller</a> from Engine Yard.</p>
<p>For Ubuntu Linux, there are several useful guides:</p>
<ul>
<li><a href="http://www.mirceagoia.com/downloads/Installation_Ruby-on-Rails_for_Ubuntu-Linux-Mint_www-mirceagoia-com.pdf">Mircea Goia’s tutorial</a></li>
<li><a href="https://github.com/joshfng/railsready">Joshua Frye’s Rails Ready setup script</a></li>
<li><a href="http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/">Ryan Bigg’s tutorial</a></li>
<li><a href="http://www.rubyinside.com/how-to-install-ruby-1-9-2-and-rails-3-0-on-ubuntu-10-10-4148.html">Peter Cooper’s screencast</a></li>
</ul><h4>Install or Update <span class="caps">RVM</span>
</h4>
<p>Use rvm, the <a href="http://rvm.beginrescueend.com/">Ruby Version Manager</a>, to manage your Rails versions and create a gemset specifically for each application you build. If you encounter conflicting gem dependencies, you can isolate the errors by creating different gemsets with rvm.</p>
<p>The rvm website explains <a href="https://rvm.beginrescueend.com/rvm/install/">how to install rvm</a>.</p>
<p>On a Mac, you may encounter issues with rvm and XCode 4.2 (or newer) because XCode 4.2 doesn’t use the standard gcc compiler. Here’s a <a href="http://www.andygoundry.com/2011/11/16/making-rvm-gemsets-work-under-os-x-lion-with-xcode-4-2/">suggested fix</a>.</p>
<p>If you already have rvm installed, update it to the latest version.</p>
<pre>
$ rvm get latest
$ rvm reload
$ rvm -v
</pre>
<h4>Install Ruby 1.9.3</h4>
<p>Check for the current <a href="http://www.ruby-lang.org/en/downloads/">recommended version of Ruby</a>. Ruby 1.9.3 patch level 0 was current when this was written.</p>
<p>If you don’t have it already, use rvm to install the recommended version of Ruby and make it your default:</p>
<pre>
$ rvm install ruby-1.9.3-p0
$ rvm --default use ruby-1.9.3-p0
$ ruby -v
</pre>
<h4>RubyGems</h4>
<p>The RubyGems package management system comes as part of a standard Ruby language installation.</p>
<p>What version of the RubyGems system is installed on your machine? Check with:</p>
<p><code>$ gem -v</code></p>
<p>Check for the <a href="https://rubygems.org/gems/rubygems-update">newest version of RubyGems</a>. It should be version 1.8.11 or newer.</p>
<p>Use <code>gem update --system</code> to upgrade the RubyGems system.</p>
<p>See the article <a href="http://railsapps.github.com/managing-rails-versions-gems.html">Managing Rails Versions and Gems</a> if you have problems with gem incompatibilities.</p>
<h4>Create a Rails 3.1.3 Gemset</h4>
<p>Create a default Rails 3.1.3 gemset. It’s advisable to create a new gemset for each application you build. But to get started, create just one new Rails 3.1.3 gemset as your default.</p>
<pre>
$ rvm ruby-1.9.3-p0@rails313 --create --default
</pre>
<p>To see a list of the gemsets you have installed:</p>
<pre>
$ rvm gemset list
</pre>
<p>And see a list of the gems included with the standard Ruby installation:</p>
<pre>
$ gem list
</pre>
<h4>Update Rake</h4>
<p>Rake version 0.9.2.2 comes with Ruby 1.9.3.</p>
<p>Make sure you are using the <a href="http://rubygems.org/gems/rake">newest version of Rake</a> before you install Rails 3.1.3.</p>
<pre>
$ gem update rake
$ rake --version
</pre>
<h4>Install Rails 3.1.3</h4>
<p>Now you can install Rails 3.1.3.</p>
<p>Check for the <a href="http://rubygems.org/gems/rails">current version of Rails</a>.</p>
<p>If you want the most recent stable release:</p>
<pre>
$ gem install rails
$ rails -v
</pre>
<p>If you want the newest beta version or release candidate, you can install with <code>--pre</code>.</p>
<pre>
$ gem install rails --pre
$ rails -v
</pre>
<p>Or, as an alternative to <code>--pre</code>, for the newest version:</p>
<pre>
$ gem install rails -v "&gt;=3.1.3"
$ rails -v
</pre>
<p>Or you can get a specific version (sometimes the newest version is broken).</p>
<p>For example, if you want the Rails 3.1.0 final release, install with <code>--version=3.1.0</code>.</p>
<h4>JavaScript Runtime for Ubuntu</h4>
<p>For Rails 3.1, a JavaScript runtime is needed for development on Linux Ubuntu. It is not needed for Mac OS X or Windows.</p>
<p>For development on Linux Ubuntu, it’s best to install the <a href="http://nodejs.org/">Node.js</a> server-side JavaScript environment:</p>
<p><code>sudo apt-get install nodejs</code></p>
<p>and set it in your <code>$PATH</code>.</p>
<p>If you don’t install Node.js, you’ll need to add this to the Gemfile for each Rails application you build:</p>
<pre>
gem 'therubyracer'
</pre>
<h2>Generate a Rails App</h2>
<p>You can create a test application:</p>
<pre>
$ rails new testapp
</pre>
<p>Switch to the application root directory to examine and test what you’ve built.</p>
<pre>
$ cd testapp
</pre>
<h4>Quick Test</h4>
<p>For a “smoke test” to see if everything runs, display a list of Rake tasks.</p>
<pre>
$ bundle exec rake -T
</pre>
<p>Remember, it’s good practice to run <code>bundle exec rake</code> instead of <code>rake</code> in case a gem specified in your gemfile (or a dependency in the Gemfile.lock file) relies on a version of Rake that’s different from the newest one you’ve installed.</p>
<h4>More Information</h4>
<p>See the <a href="http://guides.rubyonrails.org/getting_started.html">Rails Guides</a> for an introduction to building and running a Rails app.</p>
<p>See a list of resources for <a href="http://railsapps.github.com/rails.html">Rails</a> if you’re just getting started.</p>
<h2>Get a Starter App</h2>
<p>The starter apps from the <a href="http://railsapps.github.com/">Rails Apps</a> repository provide good examples of Rails 3.1.3 apps.</p>
<p>Plus, by using one of these starter apps, you can minimize the effort needed to stay current with changing Rails and gem versions.</p>
<p>You can see an <a class="internal absent" href="/rails-3-1-3-example-gemfile.html">Example Rails 3.1.3 Gemfile</a> from the starter apps.</p>
<h4>Starter Apps</h4>
<p>Each app provides a set of useful, popular Rails gems integrated into a working application. Each example is known to work and can serve as your personal “reference implementation”. Each is an open source project. Dozens of developers use the apps, report problems as they arise, and propose solutions as GitHub issues. There is a tutorial for each one so there’s no mystery code.</p>
<table>
<tr>
<th>Author </th>
<th>Starter App </th>
<th>Tutorial </th>
<th>App Template </th>
<th>Comments </th>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails3-devise-rspec-cucumber">Devise, RSpec, Cucumber</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> Uses Devise for authentication with ActiveRecord and SQLite for a database </td>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails3-bootstrap-devise-cancan">Twitter Bootstrap, Devise, CanCan</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-bootstrap-devise-cancan.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> Devise for authentication, CanCan for authorization, Twitter Bootstrap for <span class="caps">CSS</span> </td>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails-prelaunch-signup">Startup Prelaunch Signup</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-prelaunch-signup.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> For a startup prelaunch signup site </td>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails3-mongoid-devise">Devise, Mongoid</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-mongoid-devise.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> Uses Devise for authentication with a MongoDB datastore </td>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails3-mongoid-omniauth">OmniAuth, Mongoid</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-mongoid-omniauth.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> OmniAuth for authentication with a MongoDB datastore </td>
</tr>
<tr>
<td> Daniel Kehoe </td>
<td> <a href="https://github.com/RailsApps/rails3-subdomains">Subdomains, Devise, Mongoid</a> </td>
<td> <a href="http://railsapps.github.com/tutorial-rails-subdomains.html">Tutorial</a> </td>
<td> <a href="https://github.com/RailsApps/rails3-application-templates">App Template</a> </td>
<td> Basecamp-style subdomains with Devise and MongoDB </td>
</tr>
</table><p>These starter apps were created with the <a href="https://github.com/RailsApps/rails_apps_composer">Rails Apps Composer</a> gem.</p>
<h4>Install from an Application Template</h4>
<p>You can use the files in the <a href="https://github.com/RailsApps/rails3-application-templates">Rails Application Templates</a> repository to build the starter apps.</p>
<p>Use the <code>"rails new myapp -m"</code> command to generate a Rails web application from a template.</p>
<p>You can add the <code>-T -O</code> flags to skip Test::Unit files and Active Record files.</p>
<p>See the <span class="caps">README</span> or tutorial to learn how to install, configure and run the starter application.</p>
<h2>Deploy to Heroku</h2>
<p>Heroku provides low cost, easily configured Rails application hosting. For your convenience, here are instructions for <a href="http://railsapps.github.com/rails-heroku-tutorial.html">Deploying to Heroku with Rails 3.1</a>.</p>
<h2>Using the .rvmrc file for Project-Specific Gemsets</h2>
<p>After you’ve created an rvm gemset that you’ll use for a project and begun to build the app, you can create an <strong>.rvmrc</strong> file in the application’s root directory. <span class="caps">RVM</span> recgonizes an <strong>.rvmrc</strong> file in a directory and loads the gemset specified inside.</p>
<p>Here’s how to create an <strong>.rvmrc</strong> file if you’re using a gemset named “ruby192@rails31”:</p>
<pre>
$ echo "rvm ruby192@rails31" &gt; .rvmrc
</pre>
<p>Using an <strong>.rvmrc</strong> file means you’ll automatically be using the correct Rails and gem version when you run your application on your local machine. This works best if you create an rvm gemset specifically for your application.</p>
<h2>Troubleshooting</h2>
<p>Problems? Check the <a href="http://github.com/RailsApps/rails3-application-templates/issues">issues</a>.</p>
<h4>Problems with Rake</h4>
<p>If you see:</p>
<pre>
The template ... could not be loaded.
Error: You have already activated rake 0.8.7, but your Gemfile requires rake 0.9.x.
Consider using bundle exec.
</pre>
<p>If you are using Ruby 1.9.2, you must update the standard Ruby installation from Rake 0.8.7 to Rake 0.9.2 (or <a href="http://rubygems.org/gems/rake">newer</a>) before using the application templates to generate a new Rails app. It’s advisable to update to Ruby 1.9.3 which will provide Rake 0.9.2.2.</p>
</div><!-- class="content" -->
<div class="comments">
<div class="content wikistyle gollum">
<h2>Comments and Issues</h2>
</div>
<p>Is this helpful? Please add a comment below. Your encouragement fuels the project.</p>
<p>Did you find an error? Or couldn't get something to work? For the example apps and tutorials, please create a GitHub issue in the repository for the example app. Creating a GitHub issue is the best way to make sure a problem is investigated and fixed.</p>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'railsapps'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div><!-- class="comments" -->
<div class="footer row">
<div class="span4">
<h3>Credits</h3>
<p><a href="http://danielkehoe.com/">Daniel Kehoe</a> initiated the <a href="http://railsapps.github.com/">RailsApps Project</a>. Thanks to all the users and contributors.</p>
</div>
<div class="span4">
<h3>Wiki</h3>
<p>Corrections? Additions? You can edit this page <a href="https://github.com/RailsApps/railsapps.github.com/wiki/_pages">on the wiki</a>.</p>
</div>
<div class="span4">
<h3>Last edit</h3>
<p>by <b>Daniel Kehoe</b>, 2012-07-20 23:08:42</p>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.