Broken free weekly Rails (c)

sponsored links
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.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Broken free weekly Rails (c)

  • Nan-Jing 5: When IBatis.Hibernate mixed affairs, pay attention to your SQL

    [Problem] Now, in the development of the so-called multi-storey JavaEE applications, data persistence layer is always essential, and "Automatic" of ORM - Hibernate, and "all-manual-type" of SqlMap - IBatis, equivalent data are Per ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate to use the principle of

    The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Based on JDBC, JPA Annotation achieve simple CRUD Generic Dao

    The origin of ideas are pretty long history of reasons: [Use iBATIS history] The use of iBATIS has been a long time, the system is to use the CRUD template tool to generate the code, although there are tools to generate, but looked at a lot of CRUD the Sq

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

  • spring struts2.0 hibernate bug killer 1

    exception There is no Action mapped for namespace / and action name checkLogin. - [Unknown location] com.opensymphony.xwork2.DefaultActionProxy.prepare (DefaultActionProxy.java: 186) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries