---
title: "Ruby1.9.2 On Rails3.0.0"
author: "myrev"
date: "2010-08-31T17:16:54Z"
tags: []
categories: ["编程语言"]
slug: "ruby1-9-2-on-rails3-0-0"
draft: false
lastmod: "2010-12-08T17:01:38Z"
id: 751973
url: "https://myrev.iteye.com/blog/751973"
---

Ruby1.9.2 On Rails3.0.0

Required:  
sudo aptitude install bison  
sudo aptitude install libmysqlclient-dev  
sudo aptitude install libxml2-dev libxslt-dev

```
sudo aptitude install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
```

**1. Install ruby 1.9.2 and rails3 -- In rvm**

You should install the git or ruby && gem

**1) Install rvm with Git**

&gt; bash &lt; &lt;( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

**2) Install rvm with gem**

&gt;sudo gem install rvm

&gt;rvm-install

**3) Add this line to the end of .bashrc:**  
\[\[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

The above will make the environment correct for all new terminal windows. In order to make the environment correct for the current terminal, execute this:  
source "$HOME/.rvm/scripts/rvm"

**4) Install ruby 1.9.2**  
&gt; rvm package install readline  
&gt; rvm install 1.9.2  
&gt; rvm 1.9.2  
&gt; ruby -v

**5) Install rails3 and dependences**

&gt; gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n  
&gt; gem install rails

**6) Install rspec 2.0.0beta**

&gt; gem install rspec --prerelease  
&gt; gem install rspec-rails --prerelease

**Done**

**Hopefully everything worked:**

&gt; ruby -v

  ruby 1.9.2p0

&gt; rails --version

  Rails 3.0.0

**Switching back to your system Ruby**

&gt;rvm system

**Back to your Rails3.0 environment**

&gt;rvm 1.9.2

**Use your RVM environment as your Default**

&gt;rvm 1.9.2 --default

**2. Create a new app**

&gt; rails new AC\_rails3 -d mysql

&gt; cd AC\_rails3

&gt; bundle install

&gt; rails server

 

**3. Rspec**

To configure your app to use rspec-rails, add a declaration to your Gemfile.  
  If you are using Bundler's grouping feature in your Gemfile, be sure to include  
  rspec-rails in the :development group as well as the :test group so that you  
  can access its generators and rake tasks.

#{RAILS\_PATH}/Gemfile  
Add

    group :development, :test do  
      gem "rspec-rails", "&gt;= 2.0.0.beta.19"  
      gem "webrat"  
    end

  Be sure to run the following command in each of your Rails apps if you're  
  upgrading:

   &gt; script/rails generate rspec:install

You should set config, let it autoload lib.

config/application.rb

config.autoload\_paths += %W(#{config.root}/lib)

**4. RESTful\_authentication For Rails3**

http://github.com/Satish/restful-authentication