
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
sweet-alert2-rails
Advanced tools
This library easily integrates the SweetAlert 2 library into a Rails application.
Using the same Rails markup :
= link_to 'Delete', item, method: :delete, data: { confirm: 'Are you sure you want to delete this item?' }
You go from:
To:
It is heavily based on the work from Moises Viloria with SweetAlert. Some cleaning and refactoring were made to make it compatible with SweetAlert 2.
It replaces the browser confirm dialog when using data: { confirm: 'message' } with the link_to helper with a nice looking sweet alert.
Rails >= 4.2, tested with Rails 5
Add the SweetAlert2 and sweet-alert2-rails to your Gemfile:
gem 'rails-assets-sweetalert2', '~> 5.1.1', source: 'https://rails-assets.org'
gem 'sweet-alert2-rails'
Add the following to application.js:
//= require sweetalert2
//= require sweet-alert2-rails
Add the following to application.css:
/*
*= require sweetalert2
*/
Try it:
= link_to "Delete", user, method: :delete, data: { confirm: 'Are you sure?' }
You may pass options in data:
data: {
confirm: 'Are you ready?',
'confirm-button-text': 'Im ready',
'cancel-button-text': 'No way',
'confirm-button-color': '#66CD00',
'sweet-alert-type': 'info',
text: 'This is a subtitle',
'image-url': '/pic.png'
}
Default options that will be used application wide so it is not necessary to set the option on each link. Put this object inside your app to override default options with the sweetAlertConfirmConfig object.
window.sweetAlertConfirmConfig = {
title: 'Are you sure?',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Ok'
};
Fork the repo & make a pull request with your fix or feature. Thanks :).
FAQs
Unknown package
We found that sweet-alert2-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers