2013-10-16 38 views
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" 

任何建議?由於

回答

1

你有ProductMailer

你的方法定義一個錯字應

def send_product 
@greeting = "Hi" 

mail to: "[email protected]" 
end 

而不是

def send_prodcut 
@greeting = "Hi" 

mail to: "[email protected]" 
end 
+0

很多,非常感謝 –

+0

請選擇它作爲答案,如果它解決你的問題 – usha