Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ActiveModel HelperMethods aren't getting mixed in when following the README pattern #446

Closed
ccmcbeck opened this Issue Dec 10, 2012 · 1 comment

Comments

Projects
None yet
2 participants

The custom validations are really great.

However, when I followed the README pattern of placing each validation in app/validators

class PersonOrCompanyValidator < ActiveModel::EachValidator
  def validate_each(record, attr_name, value)
    if record.first_name.empty? && record.last_name.empty? && record.company.empty?
      record.errors.add(:first_name, :person_or_company)
    end
  end
end

The class definitions work fine but the extensions to ActiveModel::Validations::HelperMethods

module ActiveModel::Validations::HelperMethods
  def validates_person_or_company(*attr_names)
    validates_with PersonOrCompanyValidator, _merge_attributes(attr_names)
  end
end

only get mixed in if I put the module code directly in the model. Am I doing something wrong?

My configuration

gem 'rails', '3.2.6'
gem 'simple_form', '2.0.4'
gem 'client_side_validations', '3.2.1'
gem 'client_side_validations-simple_form', '2.0.1'
Contributor

tagliala commented Jan 20, 2017

Hi,

I'm closing very old issues, hoping that they are not issues anymore.

If you are still having troubles, please open a new issue

@tagliala tagliala closed this Jan 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment