Skip to content

Commit

Permalink
Handle missing value_types from preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
BDQ authored and Trung Lê committed Feb 20, 2012
1 parent 3fa6c68 commit ac1b51e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions core/app/models/spree/preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ class Spree::Preference < ActiveRecord::Base
# The type conversions here should match
# the ones in spree::preferences::preferrable#convert_preference_value
def value
case self[:value_type].to_sym
when :string
self[:value].to_s
when :password
self[:value].to_s
when :decimal
BigDecimal.new(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP)
when :integer
self[:value].to_i
when :boolean
(self[:value].to_s =~ /^t/i) != nil
if self[:value_type].present?
case self[:value_type].to_sym
when :string
self[:value].to_s
when :password
self[:value].to_s
when :decimal
BigDecimal.new(self[:value].to_s).round(2, BigDecimal::ROUND_HALF_UP)
when :integer
self[:value].to_i
when :boolean
(self[:value].to_s =~ /^t/i) != nil
end
else
self[:value]
end
end

Expand Down

0 comments on commit ac1b51e

Please sign in to comment.