<Switch> Rails3 Beta Release: Key navigation

Merb and Rails from the decision of the merger began, after a year of hard work has finally released Beta version of Rights. Rails3 most important figure is the overall architect Yehuda Katz, and the entire Rails core turned to several turn, complete face-lift.

Why? I thought, DHH start when developing Rails, Ruby community is also less developed, so many things to create their own (even the prototype is to Rails and made), in order to reach a very easy to set up with the rapid development of the ideal package stacks may have to do what function the sea, coupled with limited resources, resulting in the Rails core actually tied very tight, basically an entire packet to you. To modify the expansion of it, often have to monkeypatch about. On the other hand, on how the Ruby program is a good program, did not start so many people wish to make clear, for example, Rails core filled with alias_method_chain, this matter is now considered relatively poor form.

Rails3 different times, Ruby community up. We have standard Rack interface, we have different ORM even NoSQL repository, we have different JS Libary, we have different test methods RSpec , we also have many ready-made do not need to create a new library. Rails3 basically get rid of such a close rewritten version, but reconstruction of the way to achieve this inclusive goal: to clarify the API again, completely modular, low-coupling components, greatly enhance the performance and so on. Specifically, there are several outcomes:

Use Ruby 1.8.7 or the Ruby 1.9

1.9 times finally arrived to review my speech last year slide .

Dependencies Management

Original config.gem replaced with a new Bundler used to manage all the library, use the new Gemfiles format, the original issue of multi-functional limited config.gem sucks. Now, we really do not rely on the system can be completely gems. Can refer to this model Bundle me some Rails Bundle of use

New Routes

As the full import Rack relationship, now Route is a way to Rack middleware, is implemented on the Rack-Mount . Route first sight is the new API changes, and can refer to this Revamped 3 Routes in Rails , but this is not the most important place, the most powerful is that its parameters: to access the endpoint is rack ends, The main # home is MainController.action (: home) the short (yes!! Rails3 each Controller actions are all a standard Rack app!! cool!!), you can see Yehuda's implementation instructions . Since it is a Rack endpoint, we can give it access other Rack app, such as Sinatra, this article demonstrates how to pick 3 Routing with Rack Rails , really super easy ah. We can anticipate that there will be more interesting Rack middlewares can be combined with Rails.

In addition, we can do directly in the Routes layer directly redirect and render template, you can see real-Yehuda, explained: Generic Actions in Rails 3 , is basically a simple Rack middleware.

The new Active Model

In order to achieve the goal of convergence of different ORM, Rails3 the ActiveModel the original ActiveRecord functionality out of the individual to become Module, such as callbacks, validations, serialization, observing, dirty tracking etc.. Any Class that they meet the definition of several ActiveModel API, plus you need to include Module, you can take with Rails3 together. See ActiveModel: Make Any Ruby Object Feel Like ActiveRecord.

Validation of them new API, please refer validates: rails_3,: awesome => true


That ActiveRecord itself? Introduced ARel The SQL generation tool (why Arel?), A substantial use of "method chain" series with usage, so that each operation turned into a scope.

ActiveRecord and therefore have a new API: Active Record Query Interface 3.0


Responder brought respond_with, the wording can be simplified controller, use reference Cleaner RESTful Controllers w / respond_with , Default RESTful Rendering and Three reasons to love ActionController:: Responder This is a few. This tool is very interesting, before I even wrote a plugin respond_methods to make Rails 2.x support this feature.

In addition, the new Render implementation allows you to easily extend it a Render Options in Rails 3 demonstrates how to make your own render: pdf.


Several major changes:

1. Using Erubis implementation
2. Default XSS protection open, do not forget to add h longer escape the. Please refer to SafeBuffers and Rails 3.0 for more details
3. All the JavaScript helpers into unobtrusive. You will find Rails3 of public / javascripts one more rails.js, this is a JS driver, the default is then prototype.js, jQuery is very simple to replace, just use jQuery version of rails.js on it. So did some of the Ajax Helper will be removed, if necessary in prototype_legacy_helper plugin get it back.
4. Helpers default output format is HTML 5.

Speaking of HTML5, I also recommend the reading materials Dive into HTML5 and HTML 5 Demos and Examples .


Mail this tool replaced the first floor, and can refer to this description. Then benefit from the Controller of the reconstruction results, the new Controller inherits from ActionMailer finally and with a AbstractController, to increase the number of functional ActionMailer also greatly DRY up.

The new API, please refer to New ActionMailer API in Rails 3.0

Changed its position on the final app / mailers, and on the app / models, it is not people confuse ah.


ActiveSupport there before nasty is that if you just want to use one of several features, very easy to get to know what in the end to require something, and had to load them altogether in order to Insurance. New Rails3 this thing figured out, you can only load the part you want.

Rails Application object

In order for a Process can run multiple Rails app, Rails3 use a Rails Application object to represent an entire Application of all the settings, so therefore you have the config / environment.rb features, almost all moved to config / application.rb the. In addition, Rack standard config.ru file was added to the root directory, it is particularly note the name of your Application, which will interact with other use of the name of the Application, the default is the directory name.

The new Rails Module

Was removed a few constants, RAILS_ROOT to switch Rails.root, RAILS_ENV to use Rails.env, RAILS_DEFAULT_LOGGER to use Rails.logger, etc. For details, see this The Rails Module (in Rails 3) . Into the benefits of the object, we do not need to do this kind of thing a string operations.

The new rails command

The original script / * command all removed, are replaced with the rails. For example, script / console into a rails console (can be abbreviated into the rails c), script / generate into rails generate (can be abbreviated into the rails g), script / server into a rails server (can be abbreviated into the rails s). Use rails-help can see a complete description.

Recommended Reading

Rails3 reading data is very large, the official Rails 3.0: Release Notes are required reading. If you cut into the direction from the upgrade, you can use the official upgrade Plugin Rails-Upgrade is now an official plugin , it can help you 1. checks need to upgrade the place 2. produce Gemfile 3. create new routes.rb. Please with this The Path to Rails 3: Approaching the upgrade to take. But ah, now, or do not upgrade in the Production environment better, after all, a lot of miles Plugin not keep up (you can see Is Your Plugin Ready For Rails 3? and Rails Wiki which Plugins OK with finishing up).

If it is much easier from the start, you can see The Path to Rails 3: Greenfielding new apps with the Rails 3 beta this. Is recommended if you have time, you can now begin play read.

If you want to learn more about Rails framework, there are a few articles to look at:

* The Path to Rails 3: Introduction (be the simplest one, can see)
* Rails 3 Beta is Out - A Retrospective
* Rails 3: The Great Decoupling
* Rails Edge Architecture
* Rails and Merb Merge: The Anniversary (Part 1 of 6)
* Rails and Merb Merge: Performance (Part 2 of 6)
* Rails and Merb Merge: Plugin API (Part 3 of 6)
* Merge Rails and Merb: Rails Core (Part 4 of 6)

Finally, if you are looking for more English laziness package are: Rails 3.0 Beta: 36 Links and Resources To Get Co. Going , Rails 3 Reading Material , On the way to Rails 3 - a link list


Suddenly discovered this in more detail, you can refer to ~

分类:Ruby 时间:2010-02-09 人气:358
blog comments powered by Disqus


  • PeriodicalExecuter object in prototype.js 2009-03-15

    prototype.js defined PeriodicalExecuter object, provide a certain interval of time to repeat the logic of a method call. <div></div> <script> var i = 0; var p = new PeriodicalExecuter(showTime,0.1); //Create the instance. Each 0 .1Second

  • prototype.js tutorial and prototype Chinese manual 2009-10-03

    Prototype.js collection of online tutorials and manuals Chinese prototype to facilitate the use of prototype.js 1.4 English tutorial doc format http://www.dayanmei.com/upload/prototype1.4.doc prototype.js 1.4 Chinese prototype 1.5 English tutorial an

  • Prototype.js sent using ajax get request parameters garbled Chinese solution 2009-11-01

    Version: prototype, struts1.2. Front (page introduction prototype.js): 1, prototype-ajax.jsp <%@ page language="java" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getSchem

  • prototype.js Development Notes (transfer) 1.3.1 2008-10-19

    Original Address: https: / / compdoc2cn.dev.java.net/prototype/html/prototype.js.cn.html 1.1. Prototype What is this? Perhaps you have not used it, prototype.js is a JavaScript package written by Sam Stephenson. Wonderful idea to prepare a good secti

  • prototype.js 1.4 version of the developer manual (change) 2008-10-15

    See a very good thing in the country has not been a lot of people use them is really unhappy, so I spent a lot effort into this manual is translated into Chinese, as the article is very long, so the translation of the heavy workload and some of Local

  • Tapestry5 in applying the prototype.js 1.6.1, the result zone.getBody () has been the exception 2010-04-01

    Call zone.getBody () has been reported that when abnormal, I always wonder where my code was wrong, the case, where the wrong label, Exception message is as follows: org.apache.tapestry5.runtime.ComponentEventException A component event handler metho

  • Prototype.js and spring of ajax based pagination 2010-05-26

    This is based on prototype.js for ajax page, use the spring framework, custom page label each page into the list, the list into session, only the session page list of stored pages, do not go query the database, the performance will be higher First, c

  • [Transferred] from the prototype.js javascript depth study of object-oriented features 2010-12-16

    Javascript prototype.js in-depth study from the object-oriented features js is a very powerful language, flexible and convenient. At present, I come into contact with the language which, from the grammatical point of view, only the Ruby than it Gengs

  • compared with the jQuery prototype.js 2011-01-07

    Quote http://hi.baidu.com/lantian125566/blog/item/b839a710869697cea6ef3f03.html Quote For any node in a HTML tag by adding an arbitrary In Prototype: new Insertion.After ('myId', 'Arbitrary HTML'); In jQuery: $ ('# MyId'). After ('Arbitrary HTML'); L

  • prototype.js common functions 2011-01-14

    prototype.js commonly used functions: Example to explain the function name Element.toggle alternately hide or show Element.toggle (''div1'','' div2'') Element.hide Hide Element.hide (''div1'','' div2'') Element.show Show Element.show (''div1'','' div

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.148 (s). 10 q(s)