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 String.new do |item|
     item << user.first_name
     item << user.second_name if user.second_name
     item << user.family_name
 end

Take a look at the definition of this method:

def returning(value)
    yield(value)
    value
end

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.

7.

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

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 人气:366
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

CodeWeblog.com 版权所有 黔ICP备15002463号-1

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