铁轨新手!!!如何让我的“发送”按钮调用发送电子邮件的功能(sendmail)?这就是我到目前为止所拥有的...... events_controller 中的 sendmail 没有调用!我的模型中有一个事件,我正在运行 rails 3.2.3
显示.html.erb:
<p><b>Send Results</b></p>
<%= form_tag("/events", :method => "get") do %>
<p><label for="email_recipient">Email recipient</label>:
<%= text_field 'email', 'Email recipient' %></p>
<%= submit_tag "Send" %>
<% end %>
路线.rb:
resources :events do
member do
get '/sendmail', :as => :sendmail
end
end
events_controller.rb
def sendmail
puts "sendmail"
Emailer.deliver_results_email
return if request.xhr?
render :text => 'Message sent successfully'
end
电子邮件程序.rb
class Emailer < ActionMailer::Base
#default from: "from@example.com"
def results_email
puts "RESULTS EMAIL"
#NEVER GETS THIS FAR.....
end
end