Skip to content

Instantly share code, notes, and snippets.

View ccabot's full-sized avatar

Toby Cabot ccabot

View GitHub Profile
@ccabot
ccabot / rails_admin.rb
Created January 26, 2011 19:03
patch rails_admin to use paper_trail
require "rails_admin/application_controller"
require "rails_admin/abstract_history"
module RailsAdmin
# use declarative_authorization for rails_admin's authz
class ApplicationController < ::ApplicationController
filter_access_to :all
end
@ccabot
ccabot / paper_trail.rb
Created January 26, 2011 18:58
patch paper_trail to work with RailsAdmin
require "paper_trail/version"
# Make PaperTrail's Version class quack like RailsAdmin's History
class Version
def username ; whodunnit && User.find(whodunnit).try(:email) || whodunnit ; end
def message ; "#{event} #{item_type} id #{item_id}" ; end
def table ; item_type ; end
def updated_at ; created_at ; end
# the count(*) that we select in the :number attribute comes back