顯示具有 define_method 標籤的文章。 顯示所有文章
顯示具有 define_method 標籤的文章。 顯示所有文章

2008年11月19日 星期三

validate,class,define_method,exists?,[],array

http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001640
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001701



Possible gotcha: You can‘t pass in a condition as a string e.g. "name = ‘Jamie’", this would be sanitized and then queried against the primary key column as "id = ‘name = \’Jamie"


原來這種要這樣設

2008年11月18日 星期二

validate,before,create,define_method,callback

http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M001618
http://www.ruby-doc.org/core/classes/Module.html#M001682

* (-) save
* (-) valid
* (1) before_validation
* (2) before_validation_on_create
* (-) validate
* (-) validate_on_create
* (3) after_validation
* (4) after_validation_on_create
* (5) before_save
* (6) before_create
* (-) create
* (7) after_create
* (8) after_save





define_method: 動態產生method 的好物