Skip to content
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 scopes on relationship calls #130

Open
dam13n opened this issue Mar 24, 2016 · 2 comments
Open

using scopes on relationship calls #130

dam13n opened this issue Mar 24, 2016 · 2 comments

Comments

@dam13n
Copy link

dam13n commented Mar 24, 2016

Something like this possible, where we can still have a CDQ object when querying on a relationship?

# store and product are both models
# expensive is a scope
Store.first.products.expensive

This throws an undefined methodexpensive' for #<_NSNotifyingWrapperMutableSet:0x11f8db930>>`

@kemiller
Copy link
Contributor

That should work if expensive is defined for Product

@dam13n
Copy link
Author

dam13n commented Mar 25, 2016

Hmm, I've tried and never gotten it to work. Maybe someone can confirm it working for them. Here's examples w/ removing scopes to make it simpler:

Cannot chain on this.

Account.first.transactions
# => #<_NSNotifyingWrapperMutableSet:0x111fb0470>

Can chain normally on this.

Account.all
# #<CDQ::CDQTargetedQuery:0x11333ec00 @entity_description=#<NSEntityDescription:0x11357f980> @target_class=Account @context=nil @predicate=nil @limit=nil @offset=nil @sort_descriptors=[] @saved_key=nil>

This crashes the app.

Account.first.transactions.all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants