我試圖做一個接觸的形式爲我的應用程序,但我得到一個錯誤:undefined method 'send_email' for ProductMailer:Class.
NoMethodError在StaticPagesController#email_contact,軌道4,5
我Staticpagescontroller是:
def email_contact
ProductMailer.send_email().deliver
redirect_to contact_url
end
我的電子郵件使用者是:
class Contact < ActionMailer::Base
default from: "[email protected]"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.contact.send_email.subject
#
def send_email
@greeting = "Hi"
mail to: "[email protected]"
end
end
我的路線是:
match '/show/:id', to: 'stores#show', via: 'get', :as=> 'show'
get "emailproduct/:id" => "products#email_product", :as => "email_product"
get "emailcontact" => "static_pages#email_contact", :as => "email_contact"