Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ninech/audited-timeline
https://github.com/ninech/audited-timeline
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ninech/audited-timeline
- Owner: ninech
- Created: 2015-05-13T16:08:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-10-01T05:01:34.000Z (over 1 year ago)
- Last Synced: 2024-08-31T22:49:51.316Z (4 months ago)
- Language: Ruby
- Size: 59.6 KB
- Stars: 3
- Watchers: 17
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Audit: audited_timeline.gemspec
Awesome Lists containing this project
README
# Audited Timeline
This gem provides a frontend to the [audited](https://github.com/collectiveidea/audited) gem.
![Screenshot](https://raw.githubusercontent.com/ninech/audited-timeline/master/images/screenshot.png?token=AAHmGTc4OGjO-QUvWWENxW-aR7QQu0Q2ks5VYuTjwA%3D%3D)
## Setup
Add the gem to your `Gemfile` and run `bundle install`.
```ruby
gem 'audited-timeline'
```## Usage
### Rendering the timeline
Render the `audited_timeline/list` partial and provide it the audits to be
rendered:```erb
<%= render 'audited_timeline/list', audits: @user.all_audits %>
```### Add CSS Styles
Include `audited-timeline` in your `application.scss`:
```sass
@import "audited-timeline";
```### Rendering associated audits
To ease rendering a timeline which includes associated audits, there is a
`AuditedTimeline::AuditedConcern`. Include it in your model along with `audited` and
`has_associated_audits`:```ruby
class User < ActiveRecord::Base
include AuditedTimeline::AuditedConcern
audited
has_associated_audits
end
```### Overriding an audit diff
It is possible to easily override an audit diff.
In development environment, each audit which has been rendered with the default
partial contains a HTML comment which points you to the partial you would have
to create.```html
User
...
```In this case, create in your application `app/views/audits/_user.create.html.erb`
to override this audit type.audited-timeline will provide a locale called `audit` to your partial.
### Readable object names
audited-timeline will simply call `#to_s` on your model name. To prevent having
`#` in your timeline, define `#to_s` on your `User`
model:```ruby
class User < ActiveRecord::Base
alias_attribute :to_s, :fullname
end
```