Broken free weekly Rails (c)

1. Freeze

Prevents further modifications to obj. A TypeError will be raised if modification is attempted. There is no way to unfreeze a frozen object.

2. Returning

returning do |item|
     item << user.first_name
     item << user.second_name if user.second_name
     item << user.family_name

Take a look at the definition of this method:

def returning(value)

3. Layout and content_for

Real good with rails.

Eighth book of Rails-style: layout and content_for

4. Text_field_tag and f.text_field

They exist separately in the action_view helpers in form_tag_helper.rb and form_helper.rb.

form_helper which should be said that the helper method used to generate a more suitable target active_record associated with the form, because a lot of the convenience convention.
Form_tag_helper using the form to generate a higher degree of freedom.

5. Namespace

In any case, to avoid conflict of namespace.

Ruby Namespace Conflicts

6. Method_missing

When you send a message to an object, the object executes the first method it finds on its method lookup path with the same name as the message. If it fails to find any such method, it raises a NoMethodError exception - unless you have provided the object with a method called method_missing. The method_missing method is passed the symbol of the nonexistent method, and any arguments that were passed in.

Sham This is the machinist in the way of implementation. It should be noted that, if you want to capture are the class method, so you want to define a method self.method_missing.


class A
      VALUE =  // it will fail because when run this line, class A is not yet loaded. This is quite different with Java.

8. Rspec describe

Eric asked me, rspec test describe XXXController what effect? After reading the source code in this way would have been written to test the spec of the sub-class category. Then it is one of the public methods you can call you.

9. Load_path, require, load, include

load_path the equivalent of java's class path
require the equivalent of java and load the import, but the load of each document will load conditions, and require only one load.
Does include for mixin.

分类:Ruby 时间:2009-06-09 人气:419
blog comments powered by Disqus


iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.068 (s). 13 q(s)