I have a rails 2.3.9 application that i'm migrating to rails 3.
As almost everyone, i'm having problem with rendering strings, specially JQUERY scripts that were inline. Before, that somebody tells me that in rails 3, it changed, i cannot rewrite all my scripts now. I will do it, it will be scheduled, but for now, i want to make it works.
Going to my question:
i have a controller with the following piece of code
respond_to do |format|
format.js { render :partial=>'update'}
format.html { head 406 }
end
My _update.js.erb has a mix between JS and ERB:
<% if MyClass.count > 0 %>
$('.show_object:visible').hide();
<%else%>
if($('.show_object').css('display') == 'none'){
$('.show_object').blink({times: 7})
}
<%end%>
It works in rails 2.3.9, but not in Rails 3. My question are:
I did solve it doing in my controller:
format.js {
render :js=> { render_to_string(:partial=>'update').html_safe!}
}
it works but don't looks like a good solution. Any other idea?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With