zrl3dx
zrl3dx

Reputation: 7869

Spree config files - setting things that can be set in admin panel

I've had problem with setting spree options in such manner that it will be automatically included during deployment (as here) but I've resolved it (or rather workedaround) with direct sql query.

Now I need to set some other things (mailer) and again, there is no documentation about anything related to that topic. Well, of course, there are many links to dead spree (official?) docs, I have found something "actual" here but of course it doesn't work.

Doing something like this:

config/initializers/spree.rb

Spree.config do |config|
    config.mails_from = 'foo'
end

throws no_method_error

Doing this in other way:

Spree::Config.set(foo: bar)

gives... no_method_error. Really, how I'm supposed to configure Spree without clicking through admin panel which is not an option? Do I really have to create some weirdy sql queries to imitate actions in panel?

Or maybe someone can point me to some actual docs which works with spree-1-3 which is rather not some undocumented bleeding-edge technology? Or maybe some working shop based on spree? Really, any source would do as I am scanning through net for another day and I must miss something essential, such basic thing can't be so hard in such popular framework.

Upvotes: 1

Views: 885

Answers (1)

gmacdougall
gmacdougall

Reputation: 4911

In this case, your best documentation is going to be in the code itself:

https://github.com/spree/spree/blob/v1.3.3/core/app/models/spree/app_configuration.rb

This lists all of the configuration variables available in Spree to be changed. You can set those, either at start up, or a runtime (in a rails console or something equivalent) using code like:

Spree::Config.emails_sent_from = '[email protected]'

Note that if you set these configurations in an initializer, they can still be changed in the admin interface, but will be changed back every time the initializer runs (i.e. when the application restarts)

Upvotes: 2

Related Questions