class TrustyCms::Config
def value=(param)
set a value that is not among those permitted.
so this will raise a ConfigError if you try to change a protected config entry or a RecordInvalid if you
Calling value= also applies any validations and restrictions that are found in the associated definition.
TrustyCms::Config.find_or_create_by_key('key').value = value
is equivalent to this:
TrustyCms.config['key'] = value
The usual way to use a config item:
def value=(param) newvalue = param.to_s if newvalue != self[:value] raise ConfigError, "#{self.key} cannot be changed" unless settable? || self[:value].blank? if boolean? self[:value] = (newvalue == "1" || newvalue == "true") ? "true" : "false" else self[:value] = newvalue end self.save! end self[:value] end