Home

Awesome

alertifyjs-rails Gem Version

This gem provides alertify.js for Rails.

Installation

In your Gemfile:

gem 'alertifyjs-rails'

or system wide:

$ gem install alertifyjs-rails

Usage

The alertify files will be added to the asset pipeline and available for you to use. Add the following line to app/assets/javascripts/application.js

//= require alertify

Optional js(coffe script) replace browser confirm dialog

//= require alertify/confirm-modal
//= require alertify/confirm-ujs

In order to get the CSS, add the following line to app/assets/stylesheets/application.css

/*
 *= require alertify
 *= require alertify/default
 *= require alertify/bootstrap
 */

or if you using scss app/assets/stylesheets/application.scss

 @import "alertify";
 @import "alertify/default";
 @import "alertify/bootstrap";

flash helper, add the following line in layout

<head>
<%= alertify_flash %>
</head>

or with wait timeout option

<head>
<%= alertify_flash(wait: 20) %>
</head>

or in your js request format

<%= alertify_flash_now %>

**notes The default content security policy for Rails 5.2 blocked the functionality of this flash helper. An initial workaround is to add :unsafe_inline as an option to the policy.script_src in development

policy.script_src  :self, :https, :unsafe_inline

More option? read alertify.js documentation here