Rails mailer + sendmail from a models -


I have a model that has some attached files in the show action, I have a link to open a dialog that is That shows the form.

This form is meant to send emails with files related to parent models, as well as some information about the model.

I have created a generator:

  Rail G Mailer Notification Rail G Resource Email System   

For now, I have a show Has a div in

  & lt; Div id = "dialog" style = "display: none" & gt; & Lt;% = form_for ??? Do F | & Gt%; & Lt;% = f.text_field: fromemail% & gt; & Lt;% end% & gt; & Lt; / Div & gt;   

But I do not know how to attach this model to me, because the form does not need DB. I have created a new resource, but when I use it, I get an error because the resource table is not present.

How can I do this? I think I have to attach a dialogue form with the current model.

Edit ------------

Now I have created my form and controller and mailer + model

  Mailer + Model Mail Deaf plan_notification (resource) @plans = resource mail (: = to & gt; "masked email" ,: = & gt; from 'maskedmail',: subject = & gt; 'test') end model def Save emailplan.plan_notification (self). Deliver! End and my controller def sends 'test' @emailplan = Emailplan.save (params [: emailplan]) End my routes. RB match 'emailplans / send' = & gt; 'Send Email Plan': Like: & gt; : Send_emailplan my form & lt;% = form_for @emailplan ,: as = & gt; : Emailplan, url = & gt; Send_emailplan_path do | E & Gt%; & Lt; Div & gt; To: & lt;% = e.text_field 'toemail'% & gt; & Lt; / Div & gt; & Lt; Div & gt; From: & lt;% = e.text_field 'to' Mail '% & gt; & Lt; / Div & gt; & Lt; Div & gt; Note: & lt; / Div & gt; & Lt; Div & gt; & Lt;% = e.text_area 'Note',: Rows = & gt; 5%> & lt; / Div & gt; & Lt; Div & gt; & Lt;% = e.submit 'Send Plans'% & gt; & Lt; / Div & gt; & Lt;% end% & gt;   

But with everyone, I get this error:

  parameter: {"commit" => "Send plan", "Authenticity_token" = & gt; "Maskedmail", "toemail" = & gt; "Emails with mask", "Note", "Note" = & gt; "23423423"}} Wrong 500 Internal Server Error in Error 0 (wrong number for error (2 for 2)):   

Why do I have a wrong number of arguments? Where can I determine the number of arguments for my model / controller?

Thank you.

Use short form_for instead of form_tag therefore:

  & Lt;% = form_tag '/ url / to / controller / which / send / mail / goes / do' here | F | & Gt%; & Lt;% = f.text_field 'fromemail'% & gt; & Lt;% = f.submit 'Send Email'% & gt; & Lt;% = end% & gt;   

There is a long answer that you might want to read a tutorial or two on the action mailer - I suspect you might be a little confused about the train (?); -)

Or if you wish, then the railcost: < / Div>

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -