Strappy
Strappy is in its very beginning stages. It is intended to be a collection of bootstrap helpers for Rails 4. The current version only includes a "Flash Messages" helper for displaying flash messages.
Installation
Clone the repo, git clone git://github.com/tommyschaefer/strappy.git
, or download the current version.
You can include this in your rails project by adding gem "strappy"
to your Gemfile. After running bundle install
, you will have access to Strappy's helpers and rails g strap:install
will generate Bootstrap's files for you.
Usage
Flash Messages
Flash messages can be created in two ways in your controller.
Using the string method, you declare flash messages like so: flash[:success] = "Message here"
. To make this a dismissable alert, you simply use the following form: flash[:success] = "[x] Message Here"
.
Using the hash method, you declare your message in the form: flash[:success] = { msg: "Message" }
. A dismissible alert in this notation would look like: flash[:success] = { msg: "Message", dismissible: true }
. Not that if you want a non-dismissable alert, you do not have to include the 'dismissable' attribute (although you can).
Alert types include "danger", "info", "warning", and "success." You can see what they look like respectively on the Twitter Bootstrap website.
In your view, you can render flash messages by including <%= flash_messages %>