Rails 4邮件程序未激活 - 不在Letter Opener中工作

时间:2017-02-23 20:01:10

标签: ruby-on-rails model-view-controller actionmailer

我有一个铁路邮件,我似乎无法开始工作。我有一个listings模型和一个listing_status_change模型。更新商家信息后,我需要向更改状态的人发送电子邮件。无法弄清楚我做错了什么。

listing_mailer.rb

class ListingMailer < ActionMailer::Base
  default from: "help@nooklyn.com"

  def status_change_notification(listing_change, sendee)
    @change_agent = listing_change.agent
    @listing = listing_change.listing
    @sendee = sendee
    @status = listing_change.humanable_status

    to_address = "#{@sendee.first_name} <#{@sendee.email}>"
    subject = "Listing Status Change: #{@listing.address.truncate(25)}"
    mail(to: to_address, subject: subject)
  end
end

status_change_notification.html.erb

Hiya <%= @sendee.first_name %>,<br><br>

The following listing changes were made:<br><br>

Listing: <%= @listing.address %><br><br>
Status: <%= @status %><br><br>
Changed By: <%= @change_agent.name %><br><br>

<%= link_to "Listing", @listing %>

change_status.rb

def send_notification_email(sendee)
  ListingMailer.status_change_notification(change_record, sendee)
    .deliver_later
end

schema.rb

create_table "listing_status_changes", force: :cascade do |t|
  t.integer  "listing_id"
  t.integer  "agent_id"
  t.integer  "status"
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end

0 个答案:

没有答案