-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Creating an item with a nil scope should not add it to the list #92
Comments
Overwriting the scope_condition seems to work def scope_condition
if collection_id.present?
"collection_id = #{collection_id}"
else
"id = -1"
end
end |
Hi @matteomelani ,
The correct way would be: n = NewContent.new(collection: collection_id)
n.save |
@swanandp I think you're misunderstanding the issue. If I don't want to add an item to a collection, I definitely don't want to set the position column, so that I don't incur the performance penalty of looking up the entire list of Right now I'm trying to hack around this when I discovered this issue. |
I just ran into this problem... Huge performance issue when you are first creating items then optionally adding them to a list later on... I guess the solution is to add them to some sort of temp list or something, but that seems a bit silly. Really there should be a way to only update the list if the scope variables are set... |
I'm facing this issue too. |
This doesn't sound like a bad idea. Would one of you like to take a stab at implementing it and creating a PR? Right now I guess If I hear nothing after a few weeks I'll close this until someone is happy to work on it. |
Closing due to inactivity. @thefron, @johnnyiller, @randallb, @matteomelani feel free to contribute a PR to solve this issue. |
sorry for commenting on a closed issue, |
Yes, that's definitely the case, but that'd be implemented on your end. If you want to look at a solution regarding a scope that evaluates to |
Recently stumbled upon this as well. The API of the method is now slightly different, it seems. This works for us as of today:
|
@phikes solution works for me, but yeah, this should probably be part of the library Was having an issue where all records with a |
Thank for this great gem.
I have a quesiton/issue related to default scope. Thanks for any help.
But collection_id is null.
This is creates a huge performance problem because every time I create a NewContent it is going to add to the list of item with collection_id set to null.
The text was updated successfully, but these errors were encountered: