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

Allow access to Spree::Core::Environment through Spree::Config #2291

Merged
merged 4 commits into from
Nov 3, 2017

Conversation

cbrunsdon
Copy link
Contributor

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:

  • We no longer need to understand or rely on rails initializers (which are very confusing, even for long-time rails users)
  • Providing access via Spree::Config.environment is clearer than telling people to set some things on config, and others on rails environment (see doc changes to simple_coordinator)
  • The environment works more like the other preferences, and can be reset through reset_spree_preferences (no need to keep the "old" configs around)

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.

Spree::Promotion::Rules::UserRole
]

promos.actions = %w[

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.

Spree::Promotion::Rules::UserRole
]

promos.actions = %w[

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.

@cbrunsdon cbrunsdon force-pushed the environment_through_config branch from 875c649 to 82868b8 Compare October 16, 2017 10:29
Clarke Brunsdon added 2 commits October 16, 2017 03:35
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.
@cbrunsdon cbrunsdon force-pushed the environment_through_config branch from 82868b8 to e9001a1 Compare October 16, 2017 10:35
Clarke Brunsdon added 2 commits October 16, 2017 05:20
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.
@cbrunsdon cbrunsdon force-pushed the environment_through_config branch from e9001a1 to 21ca4bd Compare October 16, 2017 12:20
Copy link
Member

@tvdeyen tvdeyen left a 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.

@jhawthorn jhawthorn merged commit 2848229 into solidusio:master Nov 3, 2017
@deodad
Copy link
Contributor

deodad commented Nov 3, 2017

(see doc changes to simple_coordinator)

Could you link this? Definitely been using Rails/Solidus for a while still get confused by the initialization process.

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

Successfully merging this pull request may close these issues.

6 participants