Implementing Flash Messages to your Website

<div class=’container’>
<% flash.each do |name, message| %>
<div class=”alert alert-<%= name %> alert-dismissible” role=”alert”>
<button type=”button” class=”close” data-dismiss=”alert” aria-label=”Close”><span aria-hidden=”true”>&times;</span></button>
<%= message %>
<% end %>
def create
product =
name: params[“name”],
price: params[“price”],
description: params[“description”],
supplier_id: rand(1..2)
image =
url: params[“url”],

flash[:success] = “Product Successfully Added!”
redirect_to ‘/products’



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store