我有一个带有select_tag的表单,我想将值传递给我的控制器然后我需要将它传递给邮件程序,所以不需要将它保存在数据库中,我无法使其工作;(干杯)
查看
<%= form_tag(:controller => "requests", :action => "sendpricelist") do %>
<%= select_tag 'pricelist', options_from_collection_for_select(Pricelist.all, :id, :name) %>
<%= submit_tag("Send pricelist")%>
<% end %>
控制器
def sendpricelist
@a = params[:pricelist] || []
@aa = "test"
SaasMailer.pricelist_request_email(@a, @aa).deliver_now
end
路线
resources :requests do
resources :updates
get '/sendpricelist/' => 'requests#sendpricelist', as: :sendpricelist
end
输出
请求参数:
{"utf8"=>"✓",
"authenticity_token"=>"Ps5qXEXhwaNNSreTC+Db2sJQ1MDfwrp3R18CyU0qp4iTUqdor6xoytNu+rKStGNhhy6tnHAUzosM0mHfbjGcKQ==",
"pricelist"=>"1",
"commit"=>"Send pricelist"}