Skip to content

Instantly share code, notes, and snippets.

@fahim
Created March 11, 2015 00:33
Show Gist options
  • Save fahim/03cfdc8ea47936d2a58b to your computer and use it in GitHub Desktop.
Save fahim/03cfdc8ea47936d2a58b to your computer and use it in GitHub Desktop.
def details
original_details = read_attribute(:details)
value = original_details.blank? ? product.try(:details) : original_details
value ||= ""
if alcohol_by_volume.present?
variations = ["#{alcohol_by_volume}%", "#{alcohol_by_volume}0%"]
variations << "#{alcohol_by_volume.to_i}%" if alcohol_by_volume % 1 == 0.0
unless variations.any? { |variation| value.to_s.include?(variation.to_s) }
value += " #{alcohol_by_volume}% alcohol by volume."
end
end
value.strip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment