From 5bf6503a8ffc6ba921d08dd4050bec4b43cbb5c6 Mon Sep 17 00:00:00 2001 From: benni Date: Fri, 20 May 2011 00:19:58 +0200 Subject: [PATCH] Included new localize_input gem. --- Gemfile | 1 + Gemfile.lock | 7 +++++++ app/models/article.rb | 18 +++--------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index 50a772bd..91b52a8a 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ gem 'rails3_acts_as_paranoid' gem 'meta_where' gem 'meta_search' gem 'inherited_resources' +gem 'localize_input', :git => "git://github.com/bennibu/localize_input.git" group :development do gem 'annotate' diff --git a/Gemfile.lock b/Gemfile.lock index a4fba99b..b5725d29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,9 @@ +GIT + remote: git://github.com/bennibu/localize_input.git + revision: 1de033997a66b3c22344799cd354e45f0dab4d32 + specs: + localize_input (0.0.1) + GEM remote: http://rubygems.org/ specs: @@ -115,6 +121,7 @@ DEPENDENCIES hirb inherited_resources jquery-rails + localize_input! meta_search meta_where mysql diff --git a/app/models/article.rb b/app/models/article.rb index 43d2d1d9..43ad5ac0 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -28,6 +28,9 @@ class Article < ActiveRecord::Base acts_as_paranoid # Avoid deleting the article for consistency of order-results extend ActiveSupport::Memoizable # Ability to cache method results. Use memoize :expensive_method + # Replace numeric seperator with database format + localize_input_of :price, :tax, :deposit + # Associations belongs_to :supplier belongs_to :article_category @@ -47,21 +50,6 @@ class Article < ActiveRecord::Base # Callbacks before_save :update_price_history before_destroy :check_article_in_use - - # Custom attribute setter that accepts decimal numbers using localized decimal separator. - def price=(price) - self[:price] = String.delocalized_decimal(price) - end - - # Custom attribute setter that accepts decimal numbers using localized decimal separator. - def tax=(tax) - self[:tax] = String.delocalized_decimal(tax) - end - - # Custom attribute setter that accepts decimal numbers using localized decimal separator. - def deposit=(deposit) - self[:deposit] = String.delocalized_decimal(deposit) - end # The financial gross, net plus tax and deposti def gross_price