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

Unscoping breaks STI subclasses, but is soon to be fixed in Rails #291

Closed
andrewhao opened this issue Nov 20, 2017 · 5 comments
Closed

Unscoping breaks STI subclasses, but is soon to be fixed in Rails #291

andrewhao opened this issue Nov 20, 2017 · 5 comments

Comments

@andrewhao
Copy link

andrewhao commented Nov 20, 2017

Upstream Rails (5.1.x) has a just-fixed issue where calling unscoped breaks any models that use STI (rails/rails#29199) due to the type condition in the where clause being removed.

This isn't really an issue, but I just wanted to flag this in case someone else stumbles across this.

Temporary workaround is to add a type: 'Subclass' field in the scope definition:

class SpecialThing < BaseThing
  acts_as_list scope: [type: 'SpecialThing']
end
@brendon
Copy link
Owner

brendon commented Nov 20, 2017

That's a tricky one hey? We could just unscope the fields we care about? If you wanted to take a look and see if there's anything we can do from our end, please do :) My timetable is full for the next 4 weeks or so unfortunately so I can't look very deeply at this.

@bsylvain
Copy link

bsylvain commented Nov 24, 2017

I have the same problem. If you already used a scope here is the workaround adapted :
acts_as_list scope: :some_container
you can do (same context as first example) :
acts_as_list scope: [:some_container, type: 'SpecialThing']

@brendon
Copy link
Owner

brendon commented Mar 19, 2018

@andrewhao, did you want to progress this issue?

@andrewhao
Copy link
Author

Hi @brendon - given I've found a workaround, I don't feel strongly about this and would defer to you on your timeline. Thanks for your work on this!

@brendon
Copy link
Owner

brendon commented Mar 19, 2018

Thanks @andrewhao, I think I'll close this as sometimes it's not possible for us to know the fields to unscope (if they're passed in as a string). And since you have a workaround, and since Rails has fixed this, over time it won't be an issue and people can come here for the workaround if needed :)

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

3 participants