Using Rails 4.2.4, ruby 2.2.2, gritter gem 1.2.0. My controller respond with js:
#posts_controller.rb
if @post.update post_params
gflash :success => "Link updated"
end
in accordion with official doc this is my js view:
#update.js.erb
<%= gflash :js => true %>
The problem is none is rendered, Rails server works fine and no problems are show in console. I have inspected the produced js and I have see this:
jQuery(function(){jQuery.gritter.add({image:'/assets/success-0b8a2dedd729f28e513472812f5483ae2817ae482c0b744c3ce56c9dd2b2bc1d.png',title:'
Success',text:'Link updated'});});
It seems the browser doesn't render the jQuery function. (I have jquery allready installed in my app) Ideas?
Solution:
Short:
<%= (gflash :js => true).html_safe %>
Long: Inspecting server response with Fiddler Web Debugger I have notice the response is like this:
If I execute the code above in chrome console I have an error:
So using the
html_safe
method works for me:<%= (gflash :js => true).html_safe %>