(Disclaimer: I''m new to rails, and running with rails --version: Rails
3.0.0.beta)
The quick overview of what I''m trying to do:
When the user hits a button that''s part of a table row, send an async
POST to my server, which (assuming success) will respond with some
javascript to twiddle the class of that table row.
All of this is happening fine, except that my js.erb file doesn''t seem
to be being rendered correctly. I''m seeing the <% %> code
executed
(after throwing in a print, via WEBrick), but <%= %> substitutions
aren''t being made. Note that .html.erb files come out fine.
Can anyone tell me what I''m doing wrong?
I''m making the button with:
<%= button_to ''C'', correct_result_path(row), :remote =>
true, :method
=> :post %>
The relevant controller function is:
def correct
@result = Result.find(params[:id])
@result.correct!
@error = @result.record.save
respond_to do |format|
format.js
end
end
My most basic "correct.js.erb" looks like this:
<%
p "correct.erb.js is being processed."
%>
var el =
document.getElementById("<%escape_javascript(@result.result_dom_id)
=>");
el.setAttribute(''class'',
''correct-result'');
The POST response looks like this (as viewed through firebug):
var el =
document.getElementById("<%escape_javascript(@result.result_dom_id)
=>");
el.setAttribute(''class'',
''correct-result'');
And here''s the WEBrick output when I POST to /results/481/correct:
"correct.erb.js is being processed."
Started POST "/results/481/correct" for 127.0.0.1 at 2010-03-15
04:58:10
Processing by ResultsController#correct as JS
Parameters: {"id"=>"481"}
[... cut SQL tracing ...]
Rendered results/correct.js.erb (0.5ms)
Completed in 41ms (Views: 1.9ms | ActiveRecord: 1.4ms) with 200
Thanks.
-pkh
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.