0

When entering log in our rails 3.1 app, ajax is used to render the input screen below. Here is the link for log:

<%= link_to 'Log', new_part_out_log_path(@part, :format => :js), :remote => true, :id => 'new_log_link' %>

And the new.js.erb as this:

$("<%= escape_javascript render(:file => 'out_logs/new.html.erb') %>").insertAfter('#new_log_link');
$('#new_log_link').hide();
$('#close').hide();

the problem is that after clicking 'Log', instead of one view, 2 identical views of out_logs/new.html.erb were rendered. What may be wrong with our code? thank so much.

user938363
  • 9,990
  • 38
  • 137
  • 303
  • Do you use `respond_to`? Maybe rails somehow decides to render the javascript and the HTML answer. How do you know that it renders it 2 times? Can you post some more controller code? – klump Apr 21 '12 at 18:19
  • We don't use reponse_to. – user938363 Apr 22 '12 at 01:07
  • It seems all of sudden every ajax starts to renders two identical views. It seems not just related to one controller. – user938363 Apr 22 '12 at 01:23
  • But how do you know that I renders it 2 times? Did you see it in the log or is something strange happening? – klump Apr 22 '12 at 14:19
  • After clicking, there are two identical views show up. Those views are generated by new.js.erb. We figure that the new.js.erb must be rendered twice. – user938363 Apr 22 '12 at 14:21
  • What does the log say? And could you post some controller code? – klump Apr 22 '12 at 14:32

1 Answers1

0

The problem is related to upgrade to ruby 1.9.3 which causes webrick server (for development) warning message and also rendering the .js.erb file twice on screen. The twice rendering problem disappears on our production server which is running nginx. The following link may help to understand the problem:

http://theresa.multimediatechnology.at/webrick-warnings-in-ruby-1-9-3/

What does "WARN Could not determine content-length of response body." mean and how to I get rid of it?

Community
  • 1
  • 1
user938363
  • 9,990
  • 38
  • 137
  • 303