Search code examples
ruby-on-railsrjs

RJS error in Ruby on Rails


Why does this:

    <%= update_page_tag do |page|
    page["femenino"].hide
  end %>

Generates this?

<script type="text/javascript">
//<![CDATA[
try {
$("femenino").hide();
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$(\"femenino\").hide();'); throw e }
//]]>
</script>

I have the DIV with ID "femenino", the update_page_tag is located after the DIV and it works but I dont like to look at that error in the source code.

Thanks


Solution

  • When the config.action_view.debug_rjs option is enabled, rails will wrap most of the javascript generated from PrototypeHelper in a try/catch block. By default config.action_view.debug_rjs is enabled in development mode only, so check your config/environments/production.rb file if you're seeing this in production.