|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Sending emails using ruby
I am having some problems adding any ruby to an email.
I have the following model Code:
class MyMailer < ActionMailer::Base
def mail(email)
@from = email[:from]
@recipients = "graham@domain.com"
@subject = "Enquiry Form"
body(:body => @email)
end
end
the following in myMailer/mail.html.erb Code:
qwwefw wefg wrge gre gqe g eqe <%=@body.body=> and i pass in a form results object to the mailer in view however this is the email i get from that template as displayed on the mongrel command line. Code:
Sent mail: To: graham@domain.com Subject: Enquiry Form Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 qwwefw wefg wrge gre gqe g eqe @body.body => As you can see for some reason the view is removing the beginning <%= meaning that it wont parse that can anyone tell me what would cause it to be removed before sending the email. I am relatively new to ruby so any help would be appreciated. |
|
#2
|
|||
|
|||
|
You have teh wrong closing tag
Code:
irb(main):001:0> require 'erb' => true irb(main):002:0> tmplt1 = "Some text <%= $value =>\n" => "Some text <%= $value =>\n" irb(main):003:0> tmplt2 = "Some text <%= $value %>\n" => "Some text <%= $value %>\n" irb(main):004:0> t1 = ERB.new(tmplt1) => #<ERB:0xb7f44f40 @src="_erbout = ''; _erbout.concat \"Some text \"; _erbout.concat \" $value =>\\n\"; _erbout", @filename=nil, @safe_level=nil> irb(main):005:0> t2 = ERB.new(tmplt2) => #<ERB:0xb7f42344 @src="_erbout = ''; _erbout.concat \"Some text \"; _erbout.concat(( $value ).to_s); _erbout.concat \"\\n\"\n_erbout", @filename=nil, @safe_level=nil> irb(main):009:0> $value = 42 => 42 irb(main):010:0> t1.run Some text $value => => nil irb(main):011:0> t2.run Some text 42 => nil irb(main):012:0> I've bolded the relevant sections above
__________________
-- I'll provide you with reference points; if they dont work, refer to something else. If you process text, this might make your life a little easier. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > Sending emails using ruby |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|