GlobalSetting.use_s3? - false

Try to solve the problem with file migration to s3. The first thing is that the command returns

 GlobalSetting.use_s3?
 false

And now the question. If loading new images works (i.e. S3 is set well) then what causes this error (I want to transfer existing images with DRY_RUN=1 rake uploads:migrate_to_s3) ?

Should I set something apart from the settings in the admin panel
I tried to edit discourse.conf like this:

DISCOURSE_S3_BUCKET=00000 \
DISCOURSE_S3_REGION=eu-west-2 \
DISCOURSE_S3_ACCESS_KEY_ID=00000 \
DISCOURSE_S3_SECRET_ACCESS_KEY=00000 \

file but it didn’t work.

Those are formatted like environment variables. They should be in the env: section of your app.yml.

2 Likes

I set it rigth now (GlobalSetting.use_s3? true )

Unfortunately, still the same mistake. Command rake uploads:migrate_to_s3 returns the error

If I am not mistaken, you cannot change global settings from the rails console; but you can change site settings from the console:

Basice example changing site setting:

pry(main)> SiteSetting.site_description
=> "My Cool Site"

pry(main)> SiteSetting.site_description = "My Great Discourse Site"
=> "My Great Discourse Site"

pry(main)> SiteSetting.site_description
=> "My Great Discourse Site"

A specific example, comparing global settings with site settings:

pry(main)> GlobalSetting.force_https
=> true

pry(main)> SiteSetting.force_https = false
false

pry(main)> SiteSetting.force_https
=> false

pry(main)> SiteSetting.force_https = true
=> true

pry(main)> GlobalSetting.force_https
=> true

pry(main)> GlobalSetting.force_https = false
NoMethodError: undefined method `force_https=' for GlobalSetting:Class
Did you mean? force_https
from (pry):61:in `__pry__'

pry(main)> GlobalSetting.force_https = true
NoMethodError: undefined method `force_https=' for GlobalSetting:Class
Did you mean? force_https
from (pry):62:in `__pry__'

When I did this type of testing from the rails console, it led me to believe that global settings cannot be changed in the application after the application is build; however site settings can be changed in the app after it is build and running.

For example, the developer email addresses are set in the container yml file, and this value cannot be changed in the app, which adds a layer of security to the site.

In some cases, we see that a global setting is assigned to a site setting, and then the site setting is used in the app and so it can be changed; however, when the global setting is used in the app, this value cannot be changed (or so it seems during testing).

This appears, based on my limited testing, to be one of the fundamental differences between global settings and site settings.

So, I think this is the underlying reason when @eextra tried to set GlobalSetting.use_s3? true, they found it did not work as expected:

pry(main)> GlobalSetting.use_s3?
=> false

pry(main)> GlobalSetting.use_s3 = true
NoMethodError: undefined method `use_s3=' for GlobalSetting:Class
Did you mean?  use_s3?
from (pry):8:in `__pry__'