---
title: "Rails3RC Note"
author: "myrev"
date: "2010-08-14T16:36:25Z"
tags: []
categories: ["编程语言"]
slug: "rails3rc-note"
draft: false
lastmod: "2010-08-14T16:38:28Z"
id: 737391
url: "https://myrev.iteye.com/blog/737391"
---

**Rails3RC Notes**

1\. ruby script/COMMAND....

 

rails &lt;command &gt;

 

```
Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate       Generate new code (short-cut alias: "g")
 console          Start the Rails console (short-cut alias: "c")
 server            Start the Rails server (short-cut alias: "s")
 dbconsole     Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new               Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"

In addition to those, there are:
 application      Generate the Rails application code
 destroy            Undo code generated with "generate"
 benchmarker  See how fast a piece of code runs
 profiler            Get profile information from a piece of code
 plugin              Install a plugin
 runner             Run a piece of code in the application environment

All commands can be run with -h for more information.
```

 

2\. it shouldn't autoload #{RAILS\_PATH}/lib

in config/application

```
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib)
```

3\. error\_messages is a plugin...

DEPRECATION WARNING: error\_messages\_for was removed from Rails and is now available as a plugin. Please install it with \`rails plugin install git://github.com/rails/dynamic\_form.git\`.

4\. Validates

```
class Film < ActiveRecord::Base
  validates :title, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
  validates :budget, :presence => true, :length => { :within => 1..10000000 }
end
```

http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/

5\. Plugin

Use toplevel init.rb; rails/init.rb is deprecated:

6\. Model before\_#{create, save, update}

If you want to override the method, you should use self.before\_#{create, save, update} instead of before\_#{create, save, update}.

7\. Validate (DEPRECATION WARNING)

Errors#on have been deprecated, use Errors#\[] instead.

8\. request#request\_uri

DEPRECATION WARNING: Using #request\_uri is deprecated. Use fullpath instead.