1
我試圖按照軌道中的一條基本規則DRY(不要重複自己) 我有以下型號在視圖中使用型號限制
class Micropost < ActiveRecord::Base
attr_accessible :content
belongs_to :user
validates :content, :presence => true, :length => { :maximum => 140 }
validates :user_id, :presence => true
default_scope :order => 'microposts.created_at DESC'
end
和形式,我限制與文本區域Java腳本
f.text_area :content,
:onKeyDown =>"textCounter(micropost_content,counter,140)",
:onKeyUP =>"textCounter(micropost_content,counter,140)"
我想在java腳本函數中使用驗證的最大值。
我該怎麼做?
感謝,像變魔術一樣 – ekrako 2012-02-01 14:02:12