Hi, I''m a newbie to ruby as well as rails so pardon me if the question is too trivial. I am using actionmailer to send out email notifications. In the body of the email there''s supposed to be a content item that''s actually a text attribute in the database. Is there an easy way to format the text attribute so that it wraps nicely at 72 columns to be sent out in an email? Currently what I do is to set the textarea to do wrap=hard but that means the text stored in the database has lots of unsightly linewraps. I found a block_format method in a MailHelper module that came with ActionMailer that seems to do what I want but I''m not sure how to call it. e.g. MailHelper.block_format(message.body) gives an error. Just block_format(message.body) didn''t work also. Any help appreciated. Thanks! cheers, mengkuan
Hi! On Tue, 15 Feb 2005, Meng Kuan wrote the following:> e.g. MailHelper.block_format(message.body) gives an error. Just > block_format(message.body) didn''t work also. >Shouldn''t it be MailHelper::block_format(text)? kind regards Wolfgang
Hi, Wolfgang Klinger wrote:> > Shouldn''t it be MailHelper::block_format(text)?I tried as you suggested but I got the following: NoMethodError in Messages#update undefined method `block_format'' for MailHelper:Module /app/models/notifier.rb:20:in `post_message'' Where notifier.rb looks like this: class Notifier < ActionMailer::Base def post_message(sender, recipients, message, message_url, message_header) @body["message_body"] = MailHelper::block_format(message.body) # most part of this method omitted end end Should I be using block_format in controllers or in the notifier (i.e. actionmailer)? cheers, mengkuan
Hi! On Tue, 15 Feb 2005, Meng Kuan wrote the following:> > Shouldn''t it be MailHelper::block_format(text)? > > I tried as you suggested but I got the following: > > NoMethodError in Messages#update > undefined method `block_format'' for MailHelper:Module >Sorry, was just a quick guess... I''m a ruby-newbie! kind regards Wolfgang