Skip to content

Instantly share code, notes, and snippets.

Avatar

James Barona jbarona

View GitHub Profile
@denniskuczynski
denniskuczynski / common_data.rb
Created May 11, 2012
Sharing common attributes and validations in Rails ActiveRecord to stay DRY
View common_data.rb
# Sharing common attributes and validations in Rails ActiveRecord to stay DRY
module CommonData
def self.included(clazz)
clazz.class_eval do
validates :duplicate_field, presence: true, length: { maximum: 255 }
attr_accessible :duplicate_field
end
end
You can’t perform that action at this time.