Class: EmailModelMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/yodel/11_email_model.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



25
26
27
# File 'lib/migrations/yodel/11_email_model.rb', line 25

def self.down(site)
  site.emails.destroy
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/migrations/yodel/11_email_model.rb', line 2

def self.up(site)
  site.records.create_model :emails do |emails|
    add_field :name, :string
    add_field :from, :string
    add_field :to, :string
    add_field :cc, :string
    add_field :bcc, :string
    add_field :subject, :string
    add_field :text_body, :text
    add_field :html_body, :html
    add_field :html_layout, :string
    emails.record_class_name = 'Email'
  end
  
  # template password reset email
  password_reset_email = site.emails.new
  password_reset_email.name = 'password_reset'
  password_reset_email.from = '[email protected]'
  password_reset_email.subject = 'Password Reset'
  password_reset_email.text_body = 'Hi <%= options["first_name"] %>, your password has been reset and is now: <%= options["new_password"] %>.'
  password_reset_email.save
end