下面是我基本上只是模仿的代码。一个专业的网页开发人员做了这个网站,所以我只是照着他们做的。但是,由于某些原因,数据没有在电子邮件中发送。但是,电子邮件确实发送。
<标题>控制器文件def createproject
@title = "Create Your Project"
@txtname = params[:txtname]
@txtemail = params[:txtemail]
@txtdates = params[:txtdates]
@tname = params[:tname]
@txtleader = params[:txtleader]
@txttree = params[:txttree]
@txtsolar = params[:txtsolar]
@txtwater = params[:txtwater]
@txtgoats = params[:txtgoats]
@txtkids = params[:txtkids]
@txthouse = params[:txthouse]
@txtroof = params[:txtroof]
@txtlatrine = params[:txtlatrine]
@txtbuild = params[:txtbuild]
if !@txtname.nil? && @txtname != ''
@isvalid = true
@data = {
:txtname => @txtname,
:txtemail => @txtemail,
:txtdates => @txtdates,
:tname => @tname,
:txtleader => @txtleader,
:txttree => @txttree,
:txtsolar => @txtsolar,
:txtwater => @txtwater,
:txtgoats => @txtgoats,
:txtkids => @txtkids,
:txthouse => @txthouse,
:txtroof => @txtroof,
:txtlatrine => @txtlatrine,
:txtbuild => @txtbuild
}
end
if @isvalid
ContactUsMailer.createproject_mail(@data).deliver
respond_to do |format|
format.html {render :layout=>"homeLayout"}
end
else
respond_to do |format|
format.html {render :layout=>"homeLayout"}
end
end
end
<标题>梅勒文件def createproject_mail(data)
@data = data
@txtname = @data[:txtname]
@txtemail = @data[:txtemail]
@txtdates = @data[:txtdates]
@tname = @data[:tname]
@txtleader = @data[:txtleader]
@txttree = @data[:txttree]
@txtsolar = @data[:txtsolar]
@txtwater = @data[:txtwater]
@txtgoats = @data[:txtgoats]
@txtkids = @data[:txtkids]
@txthouse = @data[:txthouse]
@txtroof = @data[:txtroof]
@txtlatrine = @data[:txtlatrine]
@txtbuild = @data[:txtbuild]
mail(:to => "jacob@fusionbible.com", :subject => "TEST", :from => "no-reply@mohhaiti.org")
end
标题>标题>
放到application_helper.rb
def humanize_checkbox(val)
(val && 'on' == val.downcase) ? 'Yes' : 'No'
end
将此添加到您的邮件类中。helper :application
对于视图中的复选框,调用
<%=humanize_checkbox(@txttree)%>