Comments (18)
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.
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.
Ok, I will let you know if I find something out.
from acts_as_api.
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.
Thanks for looking into that, I really appreciate that
from acts_as_api.
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.
Thanks for all your work. I can confirm the rails5 branch fixes this issue for me.
from acts_as_api.
This is the only regression that prevents the branch from being merged: #98
from acts_as_api.
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.
Very cool, thanks!
from acts_as_api.
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.
Can you provide me some failing examples so I can extend the spec suite?
from acts_as_api.
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.
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.
@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.
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.
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.
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)
- NoMethodError render_for_api with rails 5 api app HOT 7
- DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.
- Dynamic template name in extend is not supported. HOT 1
- No options found for Remove functionality. not supporting if condition HOT 1
- InvalidURIError while deploying to heroku
- Rails 3 Responder: undefined method `list_url' HOT 1
- Ruby 2.0, Rails Mongoid, and NoMethodError (undefined method `empty?' for nil:NilClass) HOT 1
- Active Model support HOT 1
- Using class methods in api_accessible definition HOT 1
- Json with all Root nodes HOT 4
- new feature HOT 4
- respond_with not working with after_filter HOT 3
- Does not use model_name when using this without ORM HOT 3
- Parent Name under association HOT 3
- can't modify frozen Hash representing deleted AR objects HOT 1
- DateTime objects are truncating milliseconds HOT 5
- introduction: confuse links
- can i have json without root element? HOT 8
- Completely custom Json output HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acts_as_api.