This gem helps in creating user-confirmable UI actions with a persistent "Don't show this message again." facility.
Add this line to your application's Gemfile:
gem 'unconfirm'
And then execute:
$ bundle
Or install it yourself as:
$ gem install unconfirm
-
DB Migration:
$ rake unconfirm_engine:install:migrations $ rake db:migrate
-
Update layout: Edit your
application.html.erb
or equivalent layout file and add the following:Just before
body
tag is closed:<%= include_unconfirm %> <%= unconfirm_tag %>
-
Include unconfirm javascript assets. Add the following to your application assets (
application.js
)://= require unconfirm
-
Add configuration file(s) for unconfirm settings:
Under
<RAILS ROOT>/config/unconfirm
add<category>_setting.yml
file with any needed settings. See [example user settings file][example] for format and documentation. [example]: config/unconfirm/example_user_settings.yml -
Enable unconfirm.
Change something like the following:
<%= f.submit "Submit", :name => "save", :class => 'link_button', :confirm => "Are you sure?" %>
to:
<%= f.submit "Submit", :name => "save", :class => 'link_button unconfirm', :data => data_with_unconfirm('skip_save_message') %>
-
Test to make sure everything works as expected.