开发者

js.erb template won't get rendered

开发者 https://www.devze.com 2023-02-17 20:21 出处:网络
I have the following code. def exception_handler(e) flash.now[:error] =e.message render \'shared/exception_handler\'

I have the following code.

def exception_handler(e)
   flash.now[:error] =  e.message
   render 'shared/exception_handler'    
end

here is the exception_handler.js.erb

$('#flash').html(' "/shared/flash_messages" )%>');
window.scrollBy(0,-10000);
$('#flash').slideDown('slow').effect('highlight', {}, 3000).del开发者_Python百科ay(4000).slideUp('slow');

How can I get it running when I rescue an exception in controller. The strange thing is it was working before I made some changes in the code this morning.


Maybe you deleted this part

$('#flash').html('<%=escape_javascript(render :partial=> "/shared/flash_messages" ).html_safe %>');


You need to add .js.erb explicitly like this:

def exception_handler(e)
   flash.now[:error] =  e.message
   render 'shared/exception_handler.js.erb'    
end

then, you need to rename exception_handler.js.erb to _exception_handler.js.erb

0

精彩评论

暂无评论...
验证码 换一张
取 消