Sha256: 56dac41a08bec8b2113be3524dad99ba40b3f80e1e39ee07ab62a85c294568bd

Contents?: true

Size: 985 Bytes

Versions: 6

Compression:

Stored size: 985 Bytes

Contents

class MessageTemplate < ActiveRecord::Base
  default_scope :order => "message_templates.position"
  has_many :message_requests

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

  acts_as_list

  def self.per_page
    10
  end

  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
#  created_at :datetime
#  updated_at :datetime
#  locale     :string(255)     default("ja")
#

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
enju_message-0.1.3 app/models/message_template.rb
enju_message-0.1.2 app/models/message_template.rb
enju_message-0.0.19 app/models/message_template.rb
enju_message-0.1.1 app/models/message_template.rb
enju_message-0.1.0 app/models/message_template.rb
enju_message-0.0.18 app/models/message_template.rb