apotonick / kaminari-cells

Kaminari pagination in Cells.
MIT License
23 stars 15 forks source link

Kaminari-cells pulls in ActionView::Helpers::TranslationHelper #4

Open johnlane opened 8 years ago

johnlane commented 8 years ago

I was having problems with translations in a cell after adding Kaminari to it.

I found that ActionView::Helpers::TranslationHelper was taking precedence over my Trailblazer::Translations. I tracked this down to kaminari-cells.rb.

#11   include ActionView::Helpers::TranslationHelper

Does this gem really need a hard dependency on ActionView::Helpers::TranslationHelper ?

As a work-around, I have put a method in the classes where I have Kaminari::Cells:

def t(*args)
  Trailblazer::Translation.t(*args)
end               
apotonick commented 8 years ago

How do you insert your Trailblazer::TranslationHelper?

johnlane commented 8 years ago

Currently I am including it into Cell::Concept in an initializer:

Cell::Concept.class_eval do
  include Cell::Erb
  include Trailblazer::Translation
  extend  Trailblazer::Translation

 ... other stuff ...

end
apotonick commented 8 years ago

You could use prepend.... cough

johnlane commented 8 years ago

The effect of prepend is to move Trailblazer::Translation up, but not up far enough...

 Kaminari::Helpers::CellsHelper,                 Kaminari::Helpers::CellsHelper,                                                                                   
 Cell::ViewModel::Partial,                       Cell::ViewModel::Partial,
 ActionView::Helpers::TranslationHelper,         ActionView::Helpers::TranslationHelper,
 Kaminari::ActionViewExtension,                  Kaminari::ActionViewExtension,
 Kaminari::Cells,                                Kaminari::Cells,
 SimpleForm::ActionViewExtensions::FormHelper,   SimpleForm::ActionViewExtensions::FormHelper,
 ActionView::Helpers::FormOptionsHelper,         ActionView::Helpers::FormOptionsHelper,
 ActionView::Helpers::JavaScriptHelper,          ActionView::Helpers::JavaScriptHelper,
                                           >     Trailblazer::Translation,
 Cell::Concept,                                  Cell::Concept,
 ActionView::RecordIdentifier,                   ActionView::RecordIdentifier,
 ActionView::ModelNaming,                        ActionView::ModelNaming,
 Trailblazer::Translation,                 <
 Cell::Erb,                                      Cell::Erb,

I've only quickly tried this, I'll give it some more attention tomorrow...

tjjjwxzq commented 7 years ago

This blows things up with cells-slim because ActionView::Helpers::TranslationHelper helpfully pulls its friend CaptureHelper along, which overrides the with_output_buffer method from Cell::Slim. Do you see a way of fixing this, or, can I open a PR to add a caveat and workaround to the README?

apotonick commented 7 years ago

We should probably just write our own translation "helper" and avoid any Rails mess code?

tjjjwxzq commented 7 years ago

Alright :+1: let me see if it's something I can look into