Closed johnlane closed 9 years ago
Your initializer is wrong, it must be
Cell::Concept.class_eval do
include ActionView::Helpers::TranslationHelper
end
and not
class Cell::Concept
include ActionView::Helpers::TranslationHelper
end
Oh hang on, I still had trouble. I could make it work with
Cell::Concept.class_eval do
include ActionView::Helpers::TranslationHelper
include Cell::Erb
end
Thanks for the test app, BTW! :heart:
I found out the problem. The Cells railtie is run after your initializer and Rails helper modules override our fixes. There's three fixes:
ApplicationCell < Cell::Concept
where you include your additional global helpers.So is the class class_eval
approach an option 4 to the above list or does 3 (ApplicationCell
) supercede that?
I've tried both methods and both work.
which one to choose - is it just a matter of personal taste ?
The class_eval
didn't work for me! :blush: It's because of the loading order of railties and all that, but I had the urge to post it anyway, so it is a solution, but only in an initializer that's run after the cell railtie. Confused enough? :laughing:
I have an initializer where I set up application-wide preferences. One thing that it does is include Cell helpers that I want to use in all Cells. Specifically, it does this:
The presnce of
include ActionView::Helpers::TranslationHelper
causes an error when rendering a form in a cell:The problem can be worked around by including
ActionView::Helpers::TranslationHelper
in each cell but it should be possible to include it once into the base class.here is a small test Rails application that demonstrates the issue. The HEAD is in the broken state. Check out the prior commit to "fix" it.