I'd like to use the mail_to method in a model

Hi all

I'd like to use the mail_to method from the views within a model:

How can I include this module into my model?

Thanks Josh

Ok, besides the obvious question of "Why on earth would you do that?", I think you can require the helper on your model, but seriously... why would you do that? It just feels wrong, you're mixing UI within your model.

Well, I often (for example in an InvoiceItem model):

   include ActionView::Helpers::NumberHelper#number_to_currency    def to_s      "%-40.40s %5d %14s %14s"%[self.description, self.units,                                number_to_currency(self.unit_price), number_to_currency(self.total)]    end

So as to not duplicate the number_to_currency functionality. But that's just a wee bit of the NumberHelper. You do know how to handle a loaded Ruby feature like 'include' don't you? BTW, it's really just    include ActionView::Helpers::NumberHelper because the # starts the comment. It's really just a little hint and just happens to look like the instance method convention of RDoc.

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

Here's how to use the mail_to helper in a view:

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001602