haml master: bug in html_safe breaks rails3 controller js code

64 views
Skip to first unread message

mz

unread,
Mar 21, 2010, 9:29:48 AM3/21/10
to Haml
there seems to be a bug in the current haml master which breaks
format.js in rails3 controller code:

format.js { render :update do |page| page.alert "foo!" end}

results in
NoMethodError (undefined method `html_safe' for ["alert(\"foo!
\");"]:Array):

from a discussion in rails-contrib (quote)
buhrmi: i replaced the the function in /lib/haml/util.rb starting with
line 215 with http://pastie.org/879571

-m

mz

unread,
Mar 21, 2010, 12:54:15 PM3/21/10
to Haml
there is a patch available already:
http://j.mp/aFHyu4

hugo carlow

unread,
Mar 21, 2010, 11:57:34 AM3/21/10
to Haml
this seems to be already adressed: http://bit.ly/aFHyu4
but still not in master of haml...

hugo carlow

unread,
Mar 21, 2010, 11:52:36 AM3/21/10
to Haml
i am having the same issue but there is also a fix for that: http://bit.ly/aFHyu4
i hope this is included in the main haml branch soon...

-hugo

On Mar 21, 2:29 pm, mz <m.ze...@gmail.com> wrote:

Nathan Weizenbaum

unread,
Mar 21, 2010, 3:10:40 PM3/21/10
to ha...@googlegroups.com
I've seen this, but I'm a little reluctant to merge the patch in until I understand what's going on. I don't get why escaping arrays works with this, or why an array is being passed to html_safe in the first place.

--
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.


mz

unread,
Mar 21, 2010, 3:42:02 PM3/21/10
to Haml
since i don't know if it is a haml or rails bug, i opened a ticket in
the rails lighthouse tracker.
http://j.mp/8YTShz

buhrmi

unread,
Mar 21, 2010, 3:45:47 PM3/21/10
to Haml
this bug prevents all calls to render(:update) for me. Dont really
care if it's a haml or rails bug, but currently its some kind of
blocker ;)

any fix would be welcome.

parasew

unread,
Mar 21, 2010, 3:31:33 PM3/21/10
to Haml
hi there,
the problem only occurred with js rendering for me.
while it might be a rails edge-issue, i was contacted by z3cko who had
a similar issue and asked me to patch it in. the original patch came
from buhrmi from #rails-contrib.

to reproduce:

1) create a link_to @foo, :remote => true
2) create a js responder in the controller: format.js { render :update
do |p| p.reload end}
3) see the output in the patched and in the unpatched version.

i think since the javascript is on more than one line, it gets treated
as an array and thats why it fails.
i will try to research more on why this behavior is actually there -
but for now everything works with that patch in rails edge... will let
you know when i have more info!

greets,
parasew

Nathan Weizenbaum

unread,
Mar 21, 2010, 7:37:43 PM3/21/10
to ha...@googlegroups.com
I've pushed a fix for this to stable. I'll release it as part of 2.2.22 some time today.


--
Reply all
Reply to author
Forward
0 new messages