I have a settings class where I want one field to be dependent of the other, but readonly -
class Setting < RailsSettings::Base
cache_prefix { "v1" }
field :default_locale, default: "en", type: :string
field :current_school_year_start, default: Time.now.year, type: :integer
field :current_school_year_end, default: -> { self.current_school_year_start + 1 }, type: :integer, readonly: true
end
When I call Setting.current_school_year_end, I get #<Proc:0x0000560e4ecef538 /development_works/UPI/app/models/setting.rb:22 (lambda)>, but if I remove the readonly part it works fine.
I have a settings class where I want one field to be dependent of the other, but readonly -
When I call
Setting.current_school_year_end
, I get#<Proc:0x0000560e4ecef538 /development_works/UPI/app/models/setting.rb:22 (lambda)>
, but if I remove thereadonly
part it works fine.