class User include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :cpf, :name validates :cpf, :cpf => true def initialize(attributes = {}) attributes.each do |key, value| instance_variable_set("@#{key}", value) end end end