0.0
No commit activity in last 3 years
No release in over 3 years
Integrate with flash-messenger to provide a simple flash messages.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

flash-messenger-rails

Build Status Coverage Status

Integrate with flash-messenger to provide a simple flash messages.

Installation

Add this line to your application's Gemfile:

gem 'flash-messenger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flash-messenger

Usage

Require Javascript

Add the following to /app/assets/javascripts/application.js:

//= require flash-messenger

Require CSS

Add the following to /app/assets/stylesheets/application.css:

/*
 *= require flash-messenger
 */

Render

Add the following to view:

<%= show_flash %>

It will render flash messages if you assign some thing to flash.

redirect_to root_path, :flash => {:error => 'Error!'}
# or
flash[:error] = 'Error!'
redirect_to root_path

In default it only shows :success, :notice, :alert, :error in flash. You can specify by this:

<%=show_flash :warning &>

Helpers

In controller, you can use helper methods to output flash messages:

flash_message('Successful!')
flash_message('Error!', :type => :error)
flash_notice('Notice!')
flash_alert('Alert!', :sticky => true)
flash_error('Error!')

You can also use it to show model errors:

flash_model_error(model)

Bootstrap

If you want to use bootstrap style, add the following to js file:

//= require flash-messenger-bootstrap

Add the following to css file:

/*
 *= require flash-messenger-bootstrap
 */

Turboboost

If you want turboboost to show errors, add the following to js file:

//= require flash-messenger-turboboost

License

The gem is available as open source under the terms of the MIT License.

Contact

The project's website is located at https://github.com/emn178/flash-messenger-rails
Author: Chen, Yi-Cyuan (emn178@gmail.com)