SunQuest
           Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 31st, 2008, 11:21 AM
g_hadgraft g_hadgraft is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 162 g_hadgraft User rank is Private First Class (20 - 50 Reputation Level)g_hadgraft User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 9 h 9 m 17 sec
Reputation Power: 4
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.

Reply With Quote
  #2  
Old March 31st, 2008, 12:17 PM
L7Sqr L7Sqr is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 585 L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 11 h 31 m 18 sec
Reputation Power: 67
Send a message via AIM to L7Sqr
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
Comments on this post
Joseph Taylor agrees!
__________________
-- 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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Sending emails using ruby


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway