Hello everyone, I''m using a gem called aws-ses and I''m trying to sophisticate the email I am sending, here is the code currently: ses = AWS::SES::Base.new(:access_key_id => ''foo'', :secret_access_key => ''bar'') email ={ :to => "#{subscriber.email}", :source => "''#{ag.name}'' <no-reply@#{ag.domain}>''", :subject => ''Hello'', :html_body => "<h1>#{subscriber.name}</h1>" } ses.send_email email However, instead of passing a hard coded string to the :html_body key, I want to pass a template in app/views/layouts/mail.html.erb Is there any method/Rails helper that lets me convert an entire template to string and pass to the html_body key? P.S: If you have already used this gem and know a/another way to help me please do it ;) Thanks in advance, everyone! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Aug 18, 2011 at 11:09 PM, Rodrigo Alves Vieira <rodrigo3n-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hello everyone, I''m using a gem called aws-ses and I''m trying to > sophisticate the email I am sending, here is the code currently: > > ses = AWS::SES::Base.new(:access_key_id => ''foo'', :secret_access_key => > ''bar'') > > > email ={ > :to => "#{subscriber.email}", > :source => "''#{ag.name}'' <no-reply@#{ag.domain}>''", > :subject => ''Hello'', > :html_body => "<h1>#{subscriber.name}</h1>" > } > > ses.send_email email > > However, instead of passing a hard coded string to the :html_body key, I > want to pass a template in app/views/layouts/mail.html.erb > > Is there any method/Rails helper that lets me convert an entire template to > string and pass to the html_body key? > > P.S: If you have already used this gem and know a/another way to help me > please do it ;) > >Sorry, I haven''t used the gem yet but if you want to evaluate an erb file, you might want to check out the ERB class. http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html> Thanks in advance, everyone! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rodrigo Alves Vieira wrote in post #1017309:> Hello everyone, I''m using a gem called aws-ses and I''m trying to > sophisticate the email I am sending, here is the code currently: > > ses = AWS::SES::Base.new(:access_key_id => ''foo'', :secret_access_key => > ''bar'') > > > email ={ > :to => "#{subscriber.email}", > :source => "''#{ag.name}'' <no-reply@#{ag.domain}>''", > :subject => ''Hello'', > :html_body => "<h1>#{subscriber.name}</h1>" > } > > ses.send_email email > > However, instead of passing a hard coded string to the :html_body key, I > want to pass a template in app/views/layouts/mail.html.erb > > Is there any method/Rails helper that lets me convert an entire template > to string and pass to the html_body key?File I/O is one of the most basic concepts in ruby: str = "" File.open(''path/to/file.txt'', ''r'') do |f| str << f.read end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.