Skip to content

Instantly share code, notes, and snippets.

@hegeltrigo
Created September 21, 2015 23:16
Show Gist options
  • Save hegeltrigo/b986ed25a71f1d1e255c to your computer and use it in GitHub Desktop.
Save hegeltrigo/b986ed25a71f1d1e255c to your computer and use it in GitHub Desktop.
class Message
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :name, :surname, :email, :phone, :country, :body, :subject
validates :name, :surname, :email, :phone, :country, :body, :presence => true
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
def country_name
if self.country
@country = Carmen::Country.coded(self.country)
@country.name
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment