Possible Duplicate:
Access a view helper for a model in rails
I know this is probably not something I should do often, but I want to use a helper within a model.
I'm generating a spreadsheet in a Report model and would like to use the time_ago_in_words
method in ActionView::Helpers::DateHelper
Is this doable, or should I be generating it in a view?
You can just include the module in the model, and use it like you would in a view
class Report
include ActionView::Helpers::DateHelper
...
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With