Sha256: 9586370254e4adfc010563ab9fa3f92c73a9e257f012a3f806ba15ce7b5d576d

Contents?: true

Size: 885 Bytes

Versions: 18

Compression:

Stored size: 885 Bytes

Contents

class Contact
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend ActiveModel::Naming

  attr_accessor :name, :email, :subject, :body

  validates_presence_of :name, message: "#{I18n.t('model.attributes.name')} #{I18n.t('activerecord.errors.messages.blank')}"
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates_format_of :email, :with => VALID_EMAIL_REGEX, message: "#{I18n.t('model.attributes.email')} #{I18n.t('activerecord.errors.messages.invalid')}"
  validates_presence_of :body, message: "#{I18n.t('model.attributes.body')} #{I18n.t('activerecord.errors.messages.blank')}"

  def initialize(attributes = {})
    attributes.each do |name, value|
      send("#{name}=", value)
    end
  end

  def self.display_name
    'Correo'
  end

  def self.get_attribute_label(label)
    return label
  end

  def persisted?
    false
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
adminpanel-2.4.0 lib/generators/adminpanel/contact/templates/contact_template.rb
adminpanel-2.3.1 lib/generators/adminpanel/contact/templates/contact_template.rb
adminpanel-2.3.0 lib/generators/adminpanel/contact/templates/contact_template.rb
adminpanel-2.2.5 app/models/contact.rb
adminpanel-2.2.4 app/models/contact.rb
adminpanel-2.2.3 app/models/contact.rb
adminpanel-2.2.2 app/models/contact.rb
adminpanel-2.2.1 app/models/contact.rb
adminpanel-2.2.0 app/models/contact.rb
adminpanel-2.1.7 app/models/contact.rb
adminpanel-2.1.6 app/models/contact.rb
adminpanel-2.1.5 app/models/contact.rb
adminpanel-2.1.3 app/models/contact.rb
adminpanel-2.1.2 app/models/contact.rb
adminpanel-2.1.1 app/models/contact.rb
adminpanel-2.1.0 app/models/contact.rb
adminpanel-2.0.1 app/models/contact.rb
adminpanel-2.0.0 app/models/contact.rb