When I create a Helper like
def update_toolbox(opts = {})
page[:toolbox_header].replace_html opts[:header] if opts[:header]
page[:toolbox_content].replace_html opts[:content] if opts[:content]
if footer = (opts[:footer] || flash[:notice])
page[:toolbox_footer].replace_html footer
end
end
And call it from an .rjs template like so:
page.update_toolbox(:content => 'foo')
I got the error
ActionView::TemplateError (ActionView::Helpers::JavaScriptProxy#to_str should return String)
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:968:in `join'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:968:in `arguments_for_call'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:1084:in `send'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:1084:in `call'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:1124:in `replace_html'
app/helpers/renderings_helper.rb:7:in `update_toolbox'
...
It's the same if I call dom_id(some_record) from a helper. It works fine if I do everything in the RJS-Template itself, but that's not very DRY.