Commit 7aa57416c2624741091394b7d033c6547b153585
1 parent
3e1f0a87
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Fix default value for settings items
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
lib/acts_as_having_settings.rb
@@ -44,7 +44,11 @@ module ActsAsHavingSettings | @@ -44,7 +44,11 @@ module ActsAsHavingSettings | ||
44 | class_eval <<-CODE | 44 | class_eval <<-CODE |
45 | def #{setting} | 45 | def #{setting} |
46 | val = send(self.class.settings_field)[:#{setting}] | 46 | val = send(self.class.settings_field)[:#{setting}] |
47 | - val.nil? ? (#{default}.is_a?(String) ? gettext(#{default}) : #{default}) : val | 47 | + if val.nil? |
48 | + val = #{default}.is_a?(String) ? gettext(#{default}) : #{default} | ||
49 | + send(self.class.settings_field)[:#{setting}] = val | ||
50 | + end | ||
51 | + val | ||
48 | end | 52 | end |
49 | def #{setting}=(value) | 53 | def #{setting}=(value) |
50 | h = send(self.class.settings_field).clone | 54 | h = send(self.class.settings_field).clone |