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

Deprecation warning from set_option_value in Rails 6.0.3.2 #3686

Open
tmtrademarked opened this issue Jun 30, 2020 · 1 comment
Open

Deprecation warning from set_option_value in Rails 6.0.3.2 #3686

tmtrademarked opened this issue Jun 30, 2020 · 1 comment
Labels
type:bug Error, flaw or fault

Comments

@tmtrademarked
Copy link
Contributor

There appears to be a deprecation warning emitted when calling variant.set_option_value in Rails 6.0.3.2. It looks like the code somewhere in Solidus is doing something potentially unsafe:

DEPRECATION WARNING: Class level methods will no longer inherit scoping from `new` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Spree::OptionValue.default_scoped`.

Solidus Version:
2.10.0

To Reproduce
Seems to occur for me whenever my code invokes variant.set_option_value, although I'm specifically noticing it in my specs. Possible that something about the test code loading path is different, although that would surprise me given the warning.

@aldesantis
Copy link
Member

This is most likely caused by this:

option_value = Spree::OptionValue.where(option_type_id: option_type.id, name: opt_value).first_or_initialize do |option|
  option.presentation = opt_value
  option.save!
end

I'm not 100% sure, but we may try calling save! outside of the first_or_initialize block (or, even simpler, use first_or_create!) instead.

@kennyadsl kennyadsl added the type:bug Error, flaw or fault label Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error, flaw or fault
Projects
None yet
Development

No branches or pull requests

3 participants