简体   繁体   中英

Client side validations and STI

I am using the client_side_validations gem. How do you suggest getting this to work with 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

Outputs:

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

Interesting. This might be a bug. Can you please open an issue on Github?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM