How do I get it to send me the first email? it only sends the last one and i want it to send both of them.
In the email and emailsoli fields, each field has a saved email.
class ReunionMailer < ApplicationMailer
default from: '[email protected]'
def autorizar_email(reunion)
@reunion = reunion
@url = 'http://example.com/login'
mail(to: @reunion.email , subject: 'Autorización de aprovador')
mail(to: @reunion.emailsoli , subject: 'Autorización de aprovador')
end
end
meeting.erb
def autorizar
if self.auto = true
ReunionMailer.autorizar_email(Reunion.find(self.id)).deliver_now
end
end
You must send a
array
with the necessary email addressesIn case you want to send a single email in which both recipients are included, the jvilla8a solution is the right one.
If what you want is to send two emails (one for each address) then you must call the method
autorizar_email
twice (once for each email); for instance:meeting_mailer.rb:
meeting.rb:
You will notice that I have removed the use of
self
since it is not necessary to use it when you want to get the value of some attribute (it is necessary if you are looking to change the value).I also changed
auto = true
(which I imagine you were really looking to useauto == true
) simply toauto
(which already returns some valuetrue
orfalse
).