Sha256: f7a8039def12379a9a7ba9a49bc00ea332e16d3a651fda87f58550312b8f5e35

Contents?: true

Size: 967 Bytes

Versions: 14

Compression:

Stored size: 967 Bytes

Contents

class MessageTemplate < ActiveRecord::Base
  default_scope :order => "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

14 entries across 14 versions & 1 rubygems

Version Path
enju_message-0.0.17 app/models/message_template.rb
enju_message-0.0.16 app/models/message_template.rb
enju_message-0.0.15 app/models/message_template.rb
enju_message-0.0.14 app/models/message_template.rb
enju_message-0.0.13 app/models/message_template.rb
enju_message-0.0.12 app/models/message_template.rb
enju_message-0.0.11 app/models/message_template.rb
enju_message-0.0.10 app/models/message_template.rb
enju_message-0.0.9 app/models/message_template.rb
enju_message-0.0.7 app/models/message_template.rb
enju_message-0.0.6 app/models/message_template.rb
enju_message-0.0.5 app/models/message_template.rb
enju_message-0.0.4 app/models/message_template.rb
enju_message-0.0.3 app/models/message_template.rb