Skip to content

sinaptia/audited-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Audited::Ui

A UI for audited, a Ruby on Rails extension for auditing models.

Installation

Add this line to your application's Gemfile:

gem "audited-ui"

And then execute:

$ bundle

Or install it yourself as:

$ gem install audited-ui

Usage

By just installing it, audited-ui will add the following routes:

/audited/audits
/audited/audits/:auditable_type
/audited/audits/:auditable_type/:auditable_id

that will allow you to audit all records of all types, all records of a given auditable type, or all records of a given auditable object, respectively.

Audit all records by linking to audited_audits_path, like this:

<%= link_to "Audit all records", audited_audits_path %>

Or just a specific auditable type, using audited_auditable_type_audits_path, like this:

<%= link_to "Audit all people records", audited_auditable_type_audits_path(auditable_type: "person") %>

Or a specific record, using audited_auditable_audits_path, like this:

<%= link_to "Audit this person", audited_auditable_audits_path(auditable_type: "person", auditable_id: person.id) %>

Customizing views

If you already set it up, you'll notice that audited-ui comes with a barebone UI that you can use. But, purposedly, the UI is very simple. The idea is that you can use it if it's good enough, but in most cases you should customize it to match your application's UI.

To generate the views simply run:

$ bundle exec rails g audited:ui:views

I18n

Every string is I18ned, even class and attributes names. See this guide if you want to translate your audited models and attributes.

By default only english and spanish are supported. You can add other locales by copying the content of this file into your app's config/locale/yourlocale.yml and translating the given strings. And if you do that send a PR :P .

If you need to customize just one string, copy that string in your app's locale file:

en:
  audited:
    ui:
      audits:
        index:
          title:
            all: Auditing everything

TODO

  • Mount the engine with a method, similar to devise_for, so we can have more and better control on routes.
  • AuditedUI configuration, if we need to configure anything.
  • Ready to use views (tailwind/bootstrap), if it makes sense.
  • Filters (by user, by dates, by changed attribute).
  • Sort by column.
  • Revert to a specific version.
  • Tests.

License

The gem is available as open source under the terms of the MIT License.