0
我試圖爲「產品類」配置「Emailer」,但是我有一個錯誤,如:未定義的ProductMailer:Class的send_product方法。在這種情況下,我定義了這種方法。 這是我的電子郵件使用者等級:ProductsController中的NoMethodError#email_product,Emailer rails 4
class ProductMailer < ActionMailer::Base
default from: "[email protected]"
# 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: "[email protected]"
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.product_mailer.spam.subject
end
,這是我的ProductsController:
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"
任何建議?由於
很多,非常感謝 –
請選擇它作爲答案,如果它解決你的問題 – usha