ã¢ãã«ã«ã³ã¼ããå ãããã¨ã§ãããªãã¼ã·ã§ã³ãç°¡åã«ã§ãã¡ããã®ã ããã¡ãã»ã¼ã¸ã¯è±èªã
ãããæ¥æ¬èªåããæ¹æ³
âãã¡ãã«æ¸ããã¦ããéããActiveHeartã®ã¤ã³ã¹ãã¼ã«ã§ãæ¥æ¬èªåæåã§ãã
Rails ãæ¥æ¬ã®ç°å¢ã§ä½¿ããããããããã® plugin ã§ããããActiveHeartãã使ã£ã¦ã¿ãã
ã»pluginã®å°å ¥
$ ruby script/plugin install http://svn.rails2u.com/public/plugins/trunk/active_heart/ããã ãã§ãActiveRecordã®validationã«ããã¨ã©ã¼ã¡ãã»ã¼ã¸ãæ¥æ¬èªåããã¾ãã
ããã«ããã£ã¼ã«ãåããæ¥æ¬èªã«ããæ¹æ³ããæ¸ããã¦ãã¾ãã
ã¾ããããã ã¨ãã£ã¼ã«ãåãè±èªã®ã¾ã¾ãªã®ã§ã
set_field_names :title=> 'ã¿ã¤ãã«'
ã¿ãããªè¨å®ã追å ããã¨ããã£ã¼ã«ãåã¨ãã¦è¨å®ãããã®ã使ç¨ããã¾ããï¼è¨å®ä¾ï¼
- -
class Item < ActiveRecord::Base
set_field_names :title=> 'ã¿ã¤ãã«'
validates_length_of :title, :in => 1..50
end
- -