Giter Site home page Giter Site logo

Comments (12)

thedanielhanke avatar thedanielhanke commented on August 18, 2024 2

ok i created a new empty project and yes - you are right.

the evil is msgpack-rails which messes(d!) around with stuff like

module ActiveRecord
  module Serialization
    include ActiveModel::Serializers::Msgpack
  end
end

recent versions look fine however.

i wonder if that "change" might still help out - i guess there are many further bad written gems out there like msgpack-rails.

however, from my side this can be marked as closed. Thank you, @gerrywastaken

from awesome_print.

thedanielhanke avatar thedanielhanke commented on August 18, 2024 1

you are welcome + cheers for this gem ;)

from awesome_print.

michaeldv avatar michaeldv commented on August 18, 2024

Check out 0.2.0. You should be able to use awesome_print with Ruby scripts that use ActiveRecord outside of Rails.

from awesome_print.

thedanielhanke avatar thedanielhanke commented on August 18, 2024

i`d rather like to use AP without beeing forced to use ActiveRecord.

from awesome_print.

gerrywastaken avatar gerrywastaken commented on August 18, 2024

@thedanielhanke or @alexw668 How did you go about creating a Rails application which does not load AR?

from awesome_print.

alexw668 avatar alexw668 commented on August 18, 2024

@gerrywastaken We have apps that uses no-SQL database like MongoDB or Neo4j (a graph database) that don't deal with AR.

from awesome_print.

gerrywastaken avatar gerrywastaken commented on August 18, 2024

@alexw668 I mean, what is the process you used to stop it from loading. As in which file did you modify and how, so I can test the issue accurately and not end up making bad assumptions about your setup.

from awesome_print.

thedanielhanke avatar thedanielhanke commented on August 18, 2024

@gerrywastaken sorry for this short delay.

head config/application.rb -n 10
require File.expand_path('../boot', __FILE__)

require 'rails'
%w(
  action_controller
  action_view
  action_mailer
).each do |framework|
  begin
    require "#{framework}/railtie"

was all i needed to do.


and ya i still miss AP :)

from awesome_print.

thedanielhanke avatar thedanielhanke commented on August 18, 2024

can be fixed like this:

    def cast_with_active_record(object, type)
      cast = cast_without_active_record(object, type)
      return cast if !defined?(::ActiveRecord)

      if object.is_a?(::ActiveRecord::Base)

should become

    def cast_with_active_record(object, type)
      cast = cast_without_active_record(object, type)
      return cast if !defined?(::ActiveRecord::Base)       #< -----------------

      if object.is_a?(::ActiveRecord::Base)

or even by unless (defined?(::ActiveRecord) || defined?(::ActiveRecord::Base)

from awesome_print.

gerrywastaken avatar gerrywastaken commented on August 18, 2024

I'm not sure how this ended up closed. I haven't yet had a chance to look into it. Thanks for the info @thedanielhanke 👍

from awesome_print.

gerrywastaken avatar gerrywastaken commented on August 18, 2024

Ok so the original bug was created a long time ago so tracking it back, the problem was originally here:
https://github.com/awesome-print/awesome_print/blob/0.1.3/lib/ap/mixin/rails.rb#L17

It then moved here:
https://github.com/awesome-print/awesome_print/blob/0.2.0/lib/ap/mixin/active_record.rb

This commit should have then fixed the issue reported by @alexw668:
05265cb#diff-e567c486212ebaee39cf4091c38a4d84R17

Then in this commit the AcitveRecord::Base check was swapped for an ActiveRecord check:
dfbebd4#diff-e567c486212ebaee39cf4091c38a4d84L17

Now this should not have affected @alexw668 as for him ActiveRecord isn't defined at all, so I'm unclear how is he would still be hitting the original bug.

@thedanielhanke Your bug appears to be that ActiveRecord is somehow getting defined by something (before awesome print is loaded), but it doesn't create ActiveRecord::Base.

Your fix is good, but I don't think it's the same issue as was reported here. I suspect the issue reported here was fixed quite some time ago. @alexw668 can you confirm?

from awesome_print.

gerrywastaken avatar gerrywastaken commented on August 18, 2024

I'm just glad your issue was solved. I think it's a good change regardless and I suspect there will be others who are affected by this issue so I'll likely merge it in.

Cheers for investigating the root cause, I really appreciate that. 👍

I suspect @alexw668 was the one who originally closed this, but can't be sure as Github isn't telling me. I'll leave this open for three more days to give @alexw668 a chance to respond.

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.