我正在尝试为“Product class”配置“Emailer”,但我有一个错误,例如:ProductMailer:Class的undefined method`send_product'。在这种情况下,我定义了该方法。 这是我的Emailer类:
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"
有什么建议吗?谢谢
答案 0 :(得分:1)
您在ProductMailer
应该是
def send_product
@greeting = "Hi"
mail to: "to@example.org"
end
而不是
def send_prodcut
@greeting = "Hi"
mail to: "to@example.org"
end