0
有兩個型號,與客戶端驗證自定義驗證
class Quote < ActiveRecord::Base
attr_accessible :quote_date
validates :quote_date, :presence => true
end
和
class Invoice < ActiveRecord::Base
attr_accessible :invoice_date
validates :invoice_date, :presence => true
validate :invoice_date_lesser
belongs_to :quote
private
def invoice_date_lesser
if invoive_date < quote_date
errors.add(:invoice_date, 'invoice date invalid')
end
end
end
會有很大的幫助,如果我能得到一些解決方案,如何做到這一點的驗證 和自定義的驗證與客戶端驗證
你是什麼意思給予Rails代碼客戶端驗證?使用'jquery'你可以驗證 –
他意味着使用[gem客戶端驗證](https://github.com/bcardarella/client_side_validations/tree/4-0-beta) –
使用client_side_validations -sorry類型錯誤 – diva