Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oleander/flyer-rb
Display user notifications in Rails programmatically
https://github.com/oleander/flyer-rb
Last synced: 4 days ago
JSON representation
Display user notifications in Rails programmatically
- Host: GitHub
- URL: https://github.com/oleander/flyer-rb
- Owner: oleander
- License: mit
- Created: 2015-02-08T22:43:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-09T14:19:24.000Z (almost 10 years ago)
- Last Synced: 2024-12-20T22:22:31.019Z (about 1 month ago)
- Language: Ruby
- Size: 176 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Flyer
Display user notifications in Rails programmatically.
## Install
`gem install flyer`
## Usage
``` ruby
# config/initializers/flyer.rb
# Use one init block for each notification
Flyer::Notification.init do |config|
# Unique id. Used to uniquely identify a notification.
config.id = "new-user"# Message to be passed to view. Is evaluated in the view context.
config.message { "Your nickname is #{current_user.nickname}" + icon("flash") }# Optional. Path to be pssed to view. Is evaluated in the controller context.
config.path { root_path }# Optional. Only display notification if this blocks evaluates to true
# The block is evaluated in the controller context.
config.on { current_user.admin? and not first_visit? }# Optional. Number of times to display the notification
# for each user. Default is 1.
config.limit = 1# Optional. When should the notification be visible?
config.valid = { from: "2015-04-01", to: "2016-04-01" }# Optional. Arbitrary data to be passed to view.
config.params = { timeout: 10 }
end# Global configuration
Flyer.configure do |config|
# Only display one notification at the time
config.max_notifications = 1
end
`````` erb
-- app/views/_notifications.html.erb (any view)
<% notifications.each do |notification| %>
<%= notification.path %>
<%= notification.message %>
<%= notification.params %>
<% end %>
```