Sha256: a76431534bce829c487bfbffe612d69727bc685205edb3809d134ebba6efa74e

Contents?: true

Size: 906 Bytes

Versions: 10

Compression:

Stored size: 906 Bytes

Contents

class MessageTemplate < ActiveRecord::Base
  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           not null
#  title      :text             not null
#  body       :text             not null
#  position   :integer
#  locale     :string           default("en")
#  created_at :datetime
#  updated_at :datetime
#

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
enju_message-0.2.4 app/models/message_template.rb
enju_message-0.2.3 app/models/message_template.rb
enju_message-0.2.2 app/models/message_template.rb
enju_message-0.2.1 app/models/message_template.rb
enju_message-0.2.0 app/models/message_template.rb
enju_message-0.2.0.beta.5 app/models/message_template.rb
enju_message-0.2.0.beta.4 app/models/message_template.rb
enju_message-0.2.0.beta.3 app/models/message_template.rb
enju_message-0.2.0.beta.2 app/models/message_template.rb
enju_message-0.2.0.beta.1 app/models/message_template.rb