kaminari: Undefined method safe_append
Kaminari master, rails 5. I have an error.
ActionView::Template::Error (undefined method `safe_append=' for "":ActiveSupport::SafeBuffer):
6: remote: data-remote
7: paginator: the paginator that renders the pagination tags inside
8: -%>
9: <%= paginator.render do -%>
10: <nav class="pagination">
21: def paginate(scope, options = {})
=> 22: paginator = Kaminari::Helpers::Paginator.new(self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false))
23: paginator.to_s
24: end
It will render if you change output_buffer like that before to_s
def paginate(scope, options = {})
paginator = Kaminari::Helpers::Paginator.new(self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :remote => false))
paginator.output_buffer = ActionView::OutputBuffer.new
paginator.to_s
end
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 18 (5 by maintainers)
Commits related to this issue
- bug fix for undefined method safe_append= fixes https://github.com/amatsuda/kaminari/issues/804 — committed to MSeneadza/kaminari by MSeneadza 8 years ago
- Update action_view_extension.rb https://github.com/amatsuda/kaminari/issues/804 — committed to dpedoneze/kaminari by dpedoneze 8 years ago
I’m not sure of the cause, but here is some basic information I’ve gathered:
@output_buffer = template.output_buffer.class.new.The implication of these two points, and the monkey patches in this thread, is that a SafeBuffer is being instantiated where an OutputBuffer should be. However, I can’t see where that is. From a brief code search, HAML seems to choose OutputBuffer.
It is also unclear to me where the call to safe_append occurs. safe_append doesn’t appear in the kaminari or HAML code base. It’s only invoked in the Rails code base in the context of ERB templates, which neither kaminari nor HAML delegate to, that I can see.
I have the same problem, but unfortunately my code base is not public so I cannot share it.
However, here’s a handy copy-pasta monkey patch for anyone needing it…
Thanks for the fix @onemanstartup I ran into the same problem