Open wedsonlima opened 3 years ago
Thanks, I'll take a look!
Ran into this today, too.
Here is one that Rubocop is a little happier about:
# frozen_string_literal: true
module AwesomePrint
module ActiveRecord
def awesome_active_model_error(object)
return object.inspect unless defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = object.respond_to?(:marshal_dump) ? marshalled_errors(object) : {}
data[:details] = object.details
data[:messages] = object.messages
"#{object} #{awesome_hash(data)}"
end
private
def marshalled_errors(object)
object_dump = object.marshal_dump.first
return object_dump.attributes unless object_dump.class.column_names == object_dump.attributes.keys
object_dump.class.column_names.each_with_object(::ActiveSupport::OrderedHash.new) do |name, hash|
next unless object_dump.has_attribute?(name) || object_dump.new_record?
value = object_dump.respond_to?(name) ? object_dump.send(name) : object_dump.read_attribute(name)
hash[name.to_sym] = value
end
end
end
end
Hi, someone working on this patch?
Guys, I pushed a PR to fix it, someone know why no CI jobs is running for that?
I ended up replacing awesome_print with a fork amazing_print which includes the fix
The
marshal_dump
method was removed fromActiveModel::Errors
in this commit and it's breaking pry console with awesome_print:output error: #<NoMethodError: undefined method marshal_dump' for #<ActiveModel::Errors:0x000055807859a148>
workaround:
https://github.com/awesome-print/awesome_print/blob/9ae56ba413b9159c826285f31e45fe5002af253a/lib/awesome_print/ext/active_record.rb#L84