-
Notifications
You must be signed in to change notification settings - Fork 526
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
Add better support for activerecord relations and mongoid criteria #662
base: master
Are you sure you want to change the base?
Conversation
I think a valuable question here is if we want to explicitly continue support for Mongoid. What does everyone think about this? I think a good discussion about it either way would be valuable, arguments for and arguments against. |
I was working with your branch and it works well but I noticed two small issues.
The ActionView partial renderer calls to_ary on the object passed the collection parameter. I was able to resolve number two by defining this method. There may be a better way already in draper. # lib/draper/relation_decorator.rb
def to_ary
relation.map(&:decorate)
end |
Hi @colinpetruno, awesome, thanks for reporting these. I'll try to get issue 2 resolved over the next few days or this weekend at the latest. |
👍 can you |
README documentation needed before merge? |
Hi @saneshark, not sure I understand your question regarding the delegate_all. If your decorator implements delegate_all, the decorated model objects returned by accessing a member of the relation will respect this as well. For example you can now do: User.decorate.page(2).per(1).first and this will return a decorated user instance. I'm happy to write up documentation for this if there is a real intention of getting this branch merged. Let me know if this is the case and I'll write up some proper docs. |
In order to properly support `render collection: Model.scope.decorate`
I'm ready to review and push it forward if one brings this up to date. |
Cleaned up implementation of #610 with Mongoid support