0

我正在尝试为“Product class”配置“Emailer”,但出现如下错误:ProductMailer:Class 的未定义方法`send_product'。在这种情况下,我定义了该方法。这是我的电子邮件类:

class ProductMailer < ActionMailer::Base
default from: "from@example.com"

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
#   en.product_mailer.send_prodcut.subject
#
def send_prodcut
@greeting = "Hi"

mail to: "to@example.org"
end

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
#   en.product_mailer.spam.subject

end

这是我的产品控制器:

class ProductsController < ApplicationController
before_filter :authenticate_authen!
before_action :set_product, only: [:show, :edit, :update, :destroy]

def email_product
ProductMailer.send_product().deliver
end

这是我的路线:

match '/login',   to: 'static_pages#login',   via: 'get'
match '/index' , to: 'stores#index', via: 'get'
match '/show/:id', to: 'stores#show', via: 'get', :as=> 'show'
get  "emailproduct" => "products#email_product", :as => "email_product"

有什么建议吗?谢谢

4

1 回答 1

1

您的方法定义有错字ProductMailer

应该

def send_product
 @greeting = "Hi"

 mail to: "to@example.org"
end

代替

def send_prodcut
 @greeting = "Hi"

 mail to: "to@example.org"
end
于 2013-10-16T21:47:26.677 回答