Rails put validation in a module mixin?

module Validations
  extend ActiveSupport::Concern

  included do
    validates :name, :length => { :minimum => 2 }, :presence => true, :uniqueness => true
    validates :name_seo, :length => { :minimum => 2 }, :presence => true, :uniqueness => true
  end
end

The validates macro must be evaluated in the context of the includer, not of the module (like you probably were doing).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)