Giter Site home page Giter Site logo

Comments (6)

martinstreicher avatar martinstreicher commented on August 19, 2024 4

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

from awesome_print.

zlenderja avatar zlenderja commented on August 19, 2024 2

I ended up replacing awesome_print with a fork amazing_print which includes the fix

https://github.com/amazing-print/amazing_print

from awesome_print.

edipofederle avatar edipofederle commented on August 19, 2024 1

Guys, I pushed a PR to fix it, someone know why no CI jobs is running for that?

from awesome_print.

BryanH avatar BryanH commented on August 19, 2024

Thanks, I'll take a look!

from awesome_print.

martinstreicher avatar martinstreicher commented on August 19, 2024

Ran into this today, too.

from awesome_print.

edipofederle avatar edipofederle commented on August 19, 2024

Hi, someone working on this patch?

from awesome_print.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.