Giter Site home page Giter Site logo

Comments (18)

fabrik42 avatar fabrik42 commented on June 10, 2024

Hi! Thank you for the bug report. Unfortunately I think I will not be able to take a look at it before next week, but I am happy to have a look at a pull request.

I think a workaround until then would be to convert the collection to an array:

render_for_api :default, json: project_with_tasks.tasks.to_a

The as_api_response method gets mixed into AR objects as well as into the Array class. Maybe we now need to mix it into another Object as well. I just want to make sure we don't clutter the namespaces of foreign classes if we don't need to.

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

I've tried .to_a but it changes the response format.

I didn't manage to fix it myself, so if you can look at it sometime next week, that'll be great.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Ok, I will let you know if I find something out.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Just a little update: I can reproduce the problem in the spec suite after updating it to Rails 5. A lot of stuff is breaking, but I'm making progress.

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

Thanks for looking into that, I really appreciate that

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Hey, I just uploaded a branch you might want to test:

I still need to make sure there are no regression bugs with older Rails versions and a little bit of polishing, but I think we can merge this soon.

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

Thanks for all your work. I can confirm the rails5 branch fixes this issue for me.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

This is the only regression that prevents the branch from being merged: #98

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

I've done a couple more tests, and I'm seeing a couple more similar issues of the above, so it's not 100% fixed, working now on creating a reproducible case.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Very cool, thanks!

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

Replacing ActiveRecord::Delegation with ActiveRecord::Relation in lib/acts_as_api.rb fixes the issue for me:

  if defined?(ActiveRecord::Delegation)
    ActiveRecord::Delegation.include(ActsAsApi::Collection)
  end
  if defined?(ActiveRecord::Relation)
    ActiveRecord::Relation.include(ActsAsApi::Collection)
  end

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Can you provide me some failing examples so I can extend the spec suite?

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

I've updated the sample app to show the issue also with the latest rails5 branch: https://github.com/shaicoleman/acts-as-api-bug

I've dug down to the root cause, and it seems to be a conflict between acts_as_api and the protected_attributes_continued gem, when the protected_attributes_continued gem is loaded first.

The workaround is either to replace ActiveRecord::Delegation with ActiveRecord::Relation or change the load order, so protected_attributes_continued loads after acts_as_api.

I don't think this is something we can test for

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Wow, thanks for updating the example app, this helped me a lot!

I am not sure why this happens, I guess the protected attributes gem changes internals from ActiveRecord. However, I think it is fine to include the collection helpers in every single AR relation class, instead of the delegation class.

I updated the PR branch accordingly.

For the other regression I was seeing, I opened a ticket in the rails repo. I am not sure of this is now intended behavior or a bug in rails. rails/rails#26959

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

@shaicoleman I think I fixed the last bug. It was a mistake on my side :\

If you can confirm that the rails 5 branch works for you, I will merge it and release a new version of the gem.

from acts_as_api.

shaicoleman avatar shaicoleman commented on June 10, 2024

Looks good, but I think you need to bump the version higher, either to 0.5.0 or to 1.0.0

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Yes, I will bump the version before the release :)

Shai Coleman schrieb:

Looks good, but I think you need to bump the version higher, either to
0.5.0 or to 1.0.0


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#100 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANqTuwQfDhh08Q7_B_z-ALeh5FA818mks5q8J-ZgaJpZM4KcGMq.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 10, 2024

Hey, I just released a new version of the gem. After the last fixes it should be completely backwards compatible, so I am releasing it under the version 0.4.4.

https://rubygems.org/gems/acts_as_api/versions/0.4.4

Thanks again for your help!

from acts_as_api.

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.