Comments (5)
Can you try it with the edge code in the repo? I'm thinking that the just-merged Decorated Collection Proxy will help with this issue.
from draper.
Yes! I just did some tests that indicate this is solved in 0.9.2. I created an ActiveRecord::Relation, then decorated it, then was able to call further AREL methods modifying the collection.
Please comment/reopen if you're still running into issues.
from draper.
Well this certainly helps.
What this does not do, however, is decorate items in the collection when chaining methods on the collection:
>> posts = PostDecorator.decorate Post.scoped
Post Load (0.1ms) SELECT "posts".* FROM "posts"
=> #<Draper::DecoratedEnumerableProxy:0x1057a44e0 @klass=PostDecorator, @context={}, @wrapped_collection=[#<Post id: 1, title: "My first post", content: "# This is an H1\r\n\r\n## This is an H2\r\n\r\n### This is ...", publish_at: "2011-10-22 18:07:00", slug: "", created_at: "2011-10-18 23:05:54", updated_at: "2011-10-22 19:00:08", public: true>]>
>> posts.where(:public => true).first
Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."public" = 't' LIMIT 1
=> #<Post id: 1, title: "My first post", content: "# This is an H1\r\n\r\n## This is an H2\r\n\r\n### This is ...", publish_at: "2011-10-22 18:07:00", slug: "", created_at: "2011-10-18 23:05:54", updated_at: "2011-10-22 19:00:08", public: true>
Notice that the Post returned from the call to #first
is not decorated!
However, I'm satisfied with what I've got working right now, and I think it's fair to call this little nuance a totally separate issue...
Thanks!
from draper.
Hmmm, now that is interesting! I don't, without more research, know much about how the ARel scopes are added together. If you look into it at all, please report back.
from draper.
FYI: I'm working on integrating draper support in ActiveAdmin here: activeadmin/activeadmin#1117
from draper.
Related Issues (20)
- Create unique context for each item in a collection?
- Draper is incompatible with Ruby 3 HOT 5
- Draper changes the behaviour of url_for when using STI models
- Sending problematic method names (open, format) to decorated rails objects sends to Kernel (conflicts with ransack)
- undefined method `auto_link' for spec with type :decorator
- Generators don't work. HOT 3
- Draper::UninferrableDecoratorError (Could not infer a decorator for Document.) HOT 3
- CI: A test MAY fail with NameError: uninitialized constant ActionMailer::Base
- Release new version HOT 7
- Breaks respond_with in Rails API apps HOT 2
- ArgumentError using helpers with Ruby 3 HOT 4
- Mongo error -> Uninitialized constant ActiveRecord Did you mean? ActiveModel HOT 1
- Usage with `Turbo::Broadcastable` HOT 1
- undefined method `attributes' for nil:NilClass
- Automatically use decorated associations in delegate methods HOT 1
- Unexpected behavior when `frozen?` method is defined in model HOT 1
- Scaffold generator: Invalid path when using --model-name=Record
- Draper still actively maintained? HOT 10
- Rails - STI bug for ActiveRecord_Relation, works fine for a single record
- issue with using draper outside of controller/view context within a rake task or (active)job
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 draper.