validates_uniqueness_of api
2008年12月4日 星期四
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"
原來這種要這樣設
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 的好物
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 的好物
2008年8月21日 星期四
validate if, RAILS_DEFAULT_LOGGER
validates_length_of :content, :in => 1..300, :on => :create, :if => lambda{ |forum| forum.user_id != 1 }
RAILS_DEFAULT_LOGGER.debug("servlet call!!!!#{last_bytestream}")
RAILS_DEFAULT_LOGGER.debug("servlet call!!!!#{last_bytestream}")
2008年6月10日 星期二
validate, validate_length_of
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001328
validates_length_of :content, :in => 1..300, :on => :create, :if => lambda{ |article| article.user_id != 1 }
:if 只有在article.user_id 不等於 1時, 才會有這樣的validate,
:on 在create的時候
validates_length_of :content, :in => 1..300, :on => :create, :if => lambda{ |article| article.user_id != 1 }
:if 只有在article.user_id 不等於 1時, 才會有這樣的validate,
:on 在create的時候
訂閱:
文章 (Atom)