We script the installation of Discourse in support of a series of internal community sites in which we want all users to default to trust level 3. However, the following approach doesn’t work for the default_trust_level setting. We set many other site settings in this manner successfully including default_invitee_trust_level, but using this approach results in a “1” for the default_trust_level.
We’re on: v1.6.0.beta2 +102
- exec:
cmd:
- su discourse -c 'RAILS_ENV=production /var/www/discourse/bin/rails r "SiteSetting.default_trust_level='"'3'"' "'
- su discourse -c 'RAILS_ENV=production /var/www/discourse/bin/rails r "SiteSetting.default_invitee_trust_level='"'3'"' "'
Thanks for the streamlining tip, but that wasn’t the cause of the issue. The default is still stuck at 1.
I was skeptical about the tip making a difference given that we have many other examples that are successfully using the overly verbose syntax. (Although the quoting is needed for strings that have spaces).
I might dig into the code to see if I can locate the cause of the issue.
Yes, when the bootstrap kicks out it will change the setting back to default (0) only if the value matches bootstrap setting value (1). Here is the relevant logic:
SiteSetting.set_and_log('default_trust_level', TrustLevel[0]) if SiteSetting.send('default_trust_level') == TrustLevel[1]
SiteSetting.set_and_log('default_email_digest_frequency', 10080) if SiteSetting.send('default_email_digest_frequency') == 1440
If the user changed default_trust_level to 3 then it will not be reverted to original value.