Search code examples
jqueryruby-on-railsclient-side-validationsti

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' \>

Solution

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