客户端验证和STI

时间:2011-08-04 17:56:33

标签: jquery ruby-on-rails client-side-validation sti

我正在使用client_side_validations gem。您如何建议将其与STI合作?

class Vehicle < ActiveRecord::Base
  validates :year, :presence => true
end

class Car < Vehicle
  validates :cylinders, :presence => true
end

class Motorcycle < Vehicle
  validates :drive_type, :presence => true
end

= form_for @motorcycle, :validate => true do |f|
  = f.text_field :year
  = f.text_field :drive_type

输出:

<input id='motorcylce_year' type='text' \>
<input data-validate='true' id='motorcylce_drive_type' type='text' \>

1 个答案:

答案 0 :(得分:0)

有趣。这可能是一个错误。你能在Github上打开一个问题吗?