implement #inspect for all Referables

This commit is contained in:
http://jneen.net/ 2017-08-01 13:20:22 -07:00
parent 0edf2b0d42
commit 15643ff91e
2 changed files with 17 additions and 0 deletions

View File

@ -25,6 +25,18 @@ module Referable
to_reference(from_project)
end
def referable_inspect
if respond_to?(:id)
"#<#{self.class.name} id:#{id} #{to_reference(full: true)}>"
else
"#<#{self.class.name} #{to_reference(full: true)}>"
end
end
def inspect
referable_inspect
end
module ClassMethods
# The character that prefixes the actual reference identifier
#

View File

@ -47,6 +47,11 @@ class User < ActiveRecord::Base
devise :lockable, :recoverable, :rememberable, :trackable,
:validatable, :omniauthable, :confirmable, :registerable
# devise overrides #inspect, so we manually use the Referable one
def inspect
referable_inspect
end
# Override Devise::Models::Trackable#update_tracked_fields!
# to limit database writes to at most once every hour
def update_tracked_fields!(request)