-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow access to Spree::Core::Environment through Spree::Config #2291
Allow access to Spree::Core::Environment through Spree::Config #2291
Conversation
core/lib/spree/app_configuration.rb
Outdated
Spree::Promotion::Rules::UserRole | ||
] | ||
|
||
promos.actions = %w[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operator = should be surrounded by a single space.
Unnecessary spacing detected.
core/lib/spree/app_configuration.rb
Outdated
Spree::Promotion::Rules::UserRole | ||
] | ||
|
||
promos.actions = %w[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operator = should be surrounded by a single space.
Unnecessary spacing detected.
875c649
to
82868b8
Compare
Currently, we have two major way of configuring solidus. The first is the reasonably-clear Spree::Config, which is an instance of Spree::AppConfiguration and contains a number of configuration settings. Secondly is the Spree::Core::Environment, which until this commit was only stored and could only be accessed through Rails.application.config.spree, though there was no clear distinction on why some settings were here and others in Spree::Config. This takes a step forward to clarify those settings, allowing access to the Spree::Core::Environment settings through `Spree::Config.environment`
Setting these "default" values during rails initializers is confusing, as understanding and/or debugging rails initializers is difficult and time consuming. By pushing the setup into the Spree::Config, we can simplify the setup of the environment and remove the confusion around when and in what order these fire. The old initializers are left so existing applications and extensions can hook into them, though they should not notice a difference.
82868b8
to
e9001a1
Compare
This is clearer and more direct than going through the rails environment, as we're setting and retrieving settings we directly control.
The Spree::Config object is an instance of AppConfiguration, and clearer than going through the rails environment to test.
e9001a1
to
21ca4bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge step into the right direction. 👍
Later we should discuss moving all configuration into the Spree::Config
object. Having some settings in Spree::Config.environment
and some in Spree::Config
is still very confusing.
Could you link this? Definitely been using Rails/Solidus for a while still get confused by the initialization process. |
This PR makes the Spree::Core::Environment (previously only accessible through Rails.application.config.spree) available via the Spree::Config.
This makes configuring Solidus easier in a few ways:
I've left the initializers in in case applications or gems are still using them, and they should be able to continue using them as before, but I think we should think about deprecating them in the future.