Rails 4.0.1
Closed this issue · 1 comments
paxer commented
"since decorators are considered as sort of helpers, you can also call any ActionView's helper methods such as content_tag or link_to"
This does not work for me, I must to include manually required modules:
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormHelper
etc
I am not sure but I found myself pretty often I need an application url_helpers are included too, in order to use __path or __url helpers in link_to method for example.
I've created a helper module and include it where needed, but I think it would be nice to have it included automatically.
module DecoratorUrlHelpers
include ActionView::Helpers::UrlHelper
def url_helpers
MyApplication::Application.routes.url_helpers
end
end
and then in my Decorator I do
module UserDecorator
include DecoratorUrlHelpers
def some_link
link_to "Darth Vader" death_star_path
end
end
amatsuda commented
Please send a failing test if this still reproduces.