我正在尝试为我的应用程序制作联系表,但出现错误:undefined method 'send_email' for ProductMailer:Class.
我的静态页面控制器是:
def email_contact
ProductMailer.send_email().deliver
redirect_to contact_url
end
我的电子邮件是:
class Contact < 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.contact.send_email.subject
#
def send_email
@greeting = "Hi"
mail to: "example@example.com"
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"