Joined April 2015
·
Posted to
Coverting Rails Flash Messages to Toastr Notifications
over 1 year
ago
Hey.
Using that code in your controller as the following:
redirect_to "/employees", :flash => { :success => "#{@employee.first_name} #{@employee.last_name} Added." }
or
flash.now[:success] = "#{@employee.first_name} #{@employee.last_name} Deleted Successfully."
both work. However, how do you get the toastr messages to show up when you have your views error message like so :
<% if @tool.errors.any? %>
<div id="error_explanation" class="bit-warning close" data-dismiss="alert">
<h2><%= pluralize(@tool.errors.count, "error") %> prohibited this tool from being saved:</h2>
<ul>
<% @tool.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
`</ul>
</div>
<% end %>
@sabril
It hasn't worked for me for the form error messages.