The discussion on how to change a site setting via the Console revolves around troubleshooting and resolving issues with Discourse settings, particularly enable_sso and force_https. Users encountered login problems after enabling SSO, with solutions involving running bundle exec rails c to modify settings directly, such as setting SiteSetting.enable_sso = falsezogstrip or SiteSetting.enable_local_logins = trueriking. Some users faced errors like Could not locate Gemfileewanly or PostgreSQL authentication issues ewanly, which were resolved by entering the container via ./launcher enter app. Alternative methods include using rails db to update the database directly, such as changing language settings Alavi1412 or bypassing regex validation Dannii. Users also shared tips for restarting the app, like using ./launcher restart appzogstrip or using rails runner for quick updates Artem_Vasiliev.
Ah, I did it a different route, but yours is easier.
I ended up doing
s = SiteSetting.find_by(name: 'enable_sso')
s.value = 'f'
s.save!
I was just about to post that here and saw your response. Thanks! Now I can at least constantly get back to a good state between tests (or maybe I should setup an actual SSO…)
URGENT: FATAL: Peer authentication failed for user “discourse”
Failed to initialize site default
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in initialize': FATAL: Peer authentication failed for user "discourse" (PG::ConnectionBad) from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in new’
from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect’
…
… many folders list
…
I did ./launcher rebuild app and tried again. The same errors!
After I’d pissed of these problems. I did restored my droplet from a previous snapshot I had and started from scratch.
changing language can be done in database in site_settings column.
just search the current language and replace new language:
below code change language from Farsi to english: UPDATE site_setting SET value = 'en' where value = 'fa_IR'
I have typed this code after typing : rails db
I believe a setting regex needs updating, and want to test with a new value, but when I go SiteSetting.key = value it blocks me because of the regex. Is there a way to force update a value even if it doesn’t match the setting’s regex?
Edit: this worked, though be very careful!
cd /var/discourse/
./launcher enter app
rails db
discourse=> update site_settings set value='newvalue' where name='settingname';
Just in case, here’s a shell script oneliner not requiring to restart Discourse: bundle exec rails runner "SiteSetting.set('enable_sso', false)". It works just like it would from Discourse Admin UI.