-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Draper with InheritedResources or ActiveAdmin #54
Comments
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. |
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. |
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 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! |
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. |
FYI: I'm working on integrating draper support in ActiveAdmin here: activeadmin/activeadmin#1117 |
I would love to use Draper with a back-end helper like ActiveAdmin... the trouble is that InheritedResources and ActiveAdmin depend a lot on scopes, and thus the ActiveRecord::Relation class.
For example:
After decorating the scoped array of Posts, we lose access to the chainable methods that ActiveAdmin is looking for...
Any thoughts?
The text was updated successfully, but these errors were encountered: