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

Rails 3.0.x in_list causes the return of default_scope #120

Closed
brendon opened this issue May 20, 2014 · 4 comments
Closed

Rails 3.0.x in_list causes the return of default_scope #120

brendon opened this issue May 20, 2014 · 4 comments

Comments

@brendon
Copy link
Owner

brendon commented May 20, 2014

I've come across this problem in the process of upgrading a Rails 2.3 app. I'm currently moving it to 3.0 and then onwards.

In Rails 3.0 there seems to be an issue where if you call Mode.unscoped.in_list (or perhaps any scope), the unscoped is overridden and the default_scope will still be applied. This causes problems when trying to calculate the bottom of the list when there is a default_scope ordering the model on the position column.

I'm not sure what to do from here but just wanted to raise the issue to see what others thought.

@brendon
Copy link
Owner Author

brendon commented May 20, 2014

Following this up, passing unscoped a block doesn't trigger this behaviour. I'll have a go at swapping this in and check that the tests still pass.

@brendon
Copy link
Owner Author

brendon commented May 20, 2014

Actually, I can't get the tests to run after running bundle in a fresh gemset on 1.9.3. Is there anything else I need to do?

@brendon
Copy link
Owner Author

brendon commented May 20, 2014

Ok, yea, looks like this is a documented thing: http://apidock.com/rails/ActiveRecord/Base/unscoped/class

You can't use scopes with unscoped in a chain. I'll make a pull request with the changes and perhaps Travis will run the tests and it'll pass...

@swanandp
Copy link
Contributor

Great, thanks for contributing!

On Tue, May 20, 2014 at 11:21 AM, Brendon Muir notifications@github.comwrote:

Ok, yea, looks like this is a documented thing:
http://apidock.com/rails/ActiveRecord/Base/unscoped/class

You can't use scopes with unscoped in a chain. I'll make a pull request
with the changes and perhaps Travis will run the tests and it'll pass...


Reply to this email directly or view it on GitHubhttps://github.com//issues/120#issuecomment-43588665
.

@brendon brendon closed this as completed Apr 17, 2016
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