title: Rails 4 - Toaster notifications rather than flash notifications
body: <p>I am using this library, (<a href="https://github.com/CodeSeven/toastr" rel="noreferrer">https://github.com/CodeSeven/toastr</a>) and I am trying to push my Flash notifications to the javascript function Toastr has provided for me. How do I call this function for every error or notification?</p>
  
  <p>This is one of the methods that are used for making a toaster notification:</p>
  
  <pre><code>toastr.warning('This is a warning!')
  </code></pre>
  
  <p>I tried making a method in the ApplicationController to see if I could call that method on default errors from CanCan. I have various versions of the method, none of which worked.</p>
  
  <pre><code>def toast(type, text)
      #if Logic here for various errors/notifications
      respond_to do |format|
          format.js { render action: "toastr.warning(#{text})", layout: false}
      end
  end
  
  def toast(type, text)
      #if Logic here for various errors/notifications
      "toastr.warning(#{text})"
  end
  </code></pre>
  
  <p>And then I try to use this method in the CanCan block:</p>
  
  <pre><code>rescue_from CanCan::AccessDenied do |exception|
      toast :error, exception.message
      redirect_to root_url
  end
  </code></pre>
  
  <p>I would assume that this is possible, but I am just unsure how to implement it. Not many try to do this, and there is probably a reason. I am open to any suggestions on how to do what I am trying to do.</p>
  
  <p>Here is a testing application that implements the Toast notifications:
  <a href="http://codeseven.github.io/toastr/demo.html" rel="noreferrer">http://codeseven.github.io/toastr/demo.html</a></p>