Sha256: 0fe1da70fee480ed76a72b756c102a3bee3820cae04756f49dfd89c5672cf7e4

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

class MessageTemplate < ActiveRecord::Base
  attr_accessible :status, :title, :body, :locale
  default_scope :order => "message_templates.position"
  has_many :message_requests

  validates_uniqueness_of :status
  validates_presence_of :status, :title, :body

  acts_as_list

  paginates_per 10

  def embed_body(options = {})
    template = Erubis::Eruby.new(body)
    context = {
      :library_group => LibraryGroup.site_config
    }.merge(options)
    template.evaluate(context)
  end

  def self.localized_template(status, locale)
    MessageTemplate.where(:status => status, :locale => locale).first || MessageTemplate.where(:status => status).first
  end
end

# == Schema Information
#
# Table name: message_templates
#
#  id         :integer          not null, primary key
#  status     :string(255)      not null
#  title      :text             not null
#  body       :text             not null
#  position   :integer
#  locale     :string(255)      default("en")
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
enju_message-0.1.14.pre14 app/models/message_template.rb
enju_message-0.1.14.pre13 app/models/message_template.rb
enju_message-0.1.14.pre12 app/models/message_template.rb
enju_message-0.1.14.pre11 app/models/message_template.rb
enju_message-0.1.14.pre10 app/models/message_template.rb
enju_message-0.1.14.pre9 app/models/message_template.rb
enju_message-0.1.14.pre8 app/models/message_template.rb
enju_message-0.1.14.pre7 app/models/message_template.rb
enju_message-0.1.14.pre6 app/models/message_template.rb
enju_message-0.1.14.pre5 app/models/message_template.rb
enju_message-0.1.14.pre4 app/models/message_template.rb
enju_trunk_message-0.1.14.pre3 app/models/message_template.rb
enju_message-0.1.14.pre3 app/models/message_template.rb