ActionView::Template::Error (undefined local variable or method `bootstrap_flash’ in production mode

Create a helper file as,   app/helpers/bootstrap_flash_helper.rb

Add these snippet into the file,

——————————————————————————–

module BootstrapFlashHelper
ALERT_TYPES = [:error, :info, :success, :warning]

def bootstrap_flash
flash_messages = []
flash.each do |type, message|
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
next if message.blank?

type = :success if type == :notice
type = :error if type == :alert
next unless ALERT_TYPES.include?(type)
Array(message).each do |msg|
text = content_tag(:div,
content_tag(:button, raw(“×”), :class => “close”, “data-dismiss” => “alert”) +
msg.html_safe, :class => “alert fade in alert-#{type}”)
flash_messages << text if msg
end
end
flash_messages.join(“\n”).html_safe
end
end

———————————————————————————-

Then call it in, app/controller/application_controller.rb

include BootstrapFlashHelper

Hope. it will help you.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s