Closed rhomeister closed 9 years ago
@apotonick Could you help me with this please? It's the only issue that is blocking deploy of Cells in our production environment ;)
+1 same problem
5 minutes .
add gem 'cells-haml'
Thanks! That did the trick.
This issue still exists for ERB users..
<%= content_tag(:div) { "hi" } %>
Provides the given error:
undefined method `encoding' for []:Array
We should add this "special behaviour" to the gems' tests, @seuros ?
Same here for erb here:
<% form_for(model) do |f| %>
<% end %>
Should I open another issue for ERB? I am not sure if it is the same issue.
I have the same problem for ERB when using form_for, and I've provided a very hacky fix below.
For some reason I don't get much of a stack trace, but I stepped through it with byebug and the error is in ActionView:Helpers:Capture:Helper
def with_output_buffer(buf = nil) #:nodoc:
unless buf
buf = ActionView::OutputBuffer.new
buf.force_encoding(output_buffer.encoding) if output_buffer
end
self.output_buffer, old_buffer = buf, output_buffer
yield
output_buffer
ensure
self.output_buffer = old_buffer
end
Something has already defined output_buffer as an empty array, which makes it die here. Digging into the cells code shows that it's this method in ViewModel:
def output_buffer
@output_buffer ||= []
end
attr_writer :output_buffer # TODO: test that, this breaks in MM.
This can be fixed by monkey patching like this, but it is bringing back ActionView:
module Cell
class ViewModel < AbstractController::Base
private
def output_buffer
@output_buffer ||= ActionView::OutputBuffer.new
end
end
end
The longer term fix would be defining output_buffer to something that supports all the methods ActionView requires.
With cells v4.0.0.beta2 and HAML v4.0.6, I'm getting the following stacktrace:
This problem is reproducible with a very simple setup. First, define a helper method that uses the content_tag method which is passed a block:
Then, use this method is in one of the HAML cell templates:
The problem does not occur if the helper is replaced by: