新的rails! 如何讓我的「發送」按鈕調用發送電子郵件的函數(sendmail)? 這是我到目前爲止...... event_controller中的sendmail不會被調用! 我有一個事件在我的模型,我的運轉軌道3.2.3rails - form_tag連接到自定義函數
show.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 %>
的routes.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
emailer.rb
class Emailer < ActionMailer::Base
#default from: "[email protected]"
def results_email
puts "RESULTS EMAIL"
#NEVER GETS THIS FAR.....
end
end