No commit activity in last 3 years
No release in over 3 years
Notifications and Alerts for Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

>= 0
 Project Readme

TheNotification

Just add JSON on HTML notifications in your APP

Designed for Bootstrap 3 style of for toastr notifications

How it works

Just remove

<%= form_for(@resource) do |f| %>
  <% if @resource.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@resource.errors.count, "error") %> prohibited this resource from being saved:</h2>

      <ul>
      <% @resource.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  # ....

<% end %>

with

<%= form_for(@post) do |f| %>
  <%= render partial: 'the_notification/form', locals: { object: @post } %>

  # ....

<% end %>

and add to Layout

<body>    
  <%= render partial: 'the_notification/flash' %>
  <%= yield %>

application.css

*= require bootstrap
*= require the_notification/vendors/toastr

application.js

//= require the_notification/vendors/toastr
//= require the_notification

$ ->
  TheNotification.show_notifications()

HTML or JSON

<%= render partial: 'the_notification/flash', locals: { format: :html } %>
<%= render partial: 'the_notification/form', locals: { object: @post, format: :html } %>

or

<%= render partial: 'the_notification/flash', locals: { format: :json } %>
<%= render partial: 'the_notification/form', locals: { object: @post, format: :json } %>

initializers/the_notification.rb

TheNotification.configure do |config|
  config.default_type = :json # :html
end

Localized errors

models/user.rb

class Post < ActiveRecord::Base
  include TheNotification::LocalizedErrors
end

config/locales/ru.yml

activerecord:
  models:
    post: Публикация
  attributes:
    post:
      title: "Загловок"

Now errors messages will looks like this:

Загловок: не может быть пустым

instead

Title: не может быть пустым

Installation

gem 'the_notification'
$ bundle

Usage

TODO: Write usage instructions here