title: virtual value total_price is saved as 1 instead of total price number
body: <p><code>total_price</code> of all products in <code>cart</code> is not saving as it should be. it shows always 1, no matter what the total price actually is. this problem got in after installing the <a href="https://github.com/RubyMoney/money" rel="nofollow">money gem</a> and <a href="https://github.com/RubyMoney/google_currency" rel="nofollow">google_currency gem</a> so I can change the price itself of the product based on locale selected not only the currency.</p>
  
  <p>so the total price is always 1, but at the same time the amount of money that I have on screen during the shopping process shows the right number,I mean if I select 2 products with price A and B, then in cart (on screen) I have the right total_price = A+B.. more than this, when I press to create the order after I fill in the fields for credit card, the ActiveMerchant sends the data to paypal and the amount of USD that goes to paypal is the total_price that I have in cart A+B.. </p>
  
  <p><strong>the problem is:</strong> why the app takes the right <code>total_price</code> and sends it to paypal, but at the same time can not store this <code>total_price</code> in the database on order create, it saves 1 instead.</p>
  
  <p>what <strong>console</strong> says when I create <strong>order</strong>:</p>
  
  <pre><code>   (0.1ms)  BEGIN
    SQL (0.4ms)  INSERT INTO `orders` (`card_expires_on`, `card_type`, `cart_id`, `created_at`, `first_name`, `ip_address`, `last_name`, `total`, `updated_at`, `user_id`) VALUES ('2012-04-01', 'visa', 5, '2012-04-18 21:35:38', 'Rosca', '127.0.0.1', 'Sergiu', 1, '2012-04-18 21:35:38', 7)
  </code></pre>
  
  <p><strong>order_transaction</strong> details:</p>
  
  <pre><code>SQL (0.5ms)  INSERT INTO `order_transactions` (`action`, `amount`, `authorization`, `created_at`, `message`, `order_id`, `params`, `success`, `updated_at`) VALUES ('purchase', 1, '0GT41652PP785722H', '2012-04-18 21:35:46', 'Success', 5, '--- \nbuild: \"2764190\"\nAck: Success\ntimestamp: \"2012-04-18T21:35:45Z\"\nTransactionID: 0GT41652PP785722H\namount: \"42.00\"\namount_currency_id: USD\ntransaction_id: 0GT41652PP785722H\nack: Success\nBuild: \"2764190\"\navs_code: X\nversion: \"62.0\"\nTimestamp: \"2012-04-18T21:35:45Z\"\nCorrelationID: 690aa904db3c\nAmount: \"42.00\"\nAVSCode: X\nVersion: \"62.0\"\ncvv2_code: M\nCVV2Code: M\ncorrelation_id: 690aa904db3c\n', 1, '2012-04-18 21:35:46')
  </code></pre>
  
  <p>a few details on how the order is created:</p>
  
  <p><strong>orders_controller.rb</strong></p>
  
  <pre><code>  def create
      @order = current_cart.build_order(params[:order])
      @order.user_id = current_user.id
      @order.total = current_cart.total_price
  #    raise current_cart.total_price.inspect
      @order.line_items = current_cart.line_items
      @order.ip_address = request.remote_ip
      if @order.save
        if @order.purchase
          Cart.destroy(session[:cart_id])
          session[:cart_id] = nil
        else
          render :action =&gt; "failure"
        end
          respond_to do |format|
            format.html { redirect_to products_path, :notice =&gt; 
            'Thank you for your order.' }
            format.json { render :json =&gt; @order }
          end
      else
         render :action =&gt; 'new'
      end
    end
  </code></pre>
  
  <p><strong>note</strong> if I activate the raise inspect line in controller I get </p>
  
  <p><code>#&lt;Money cents:4200 currency:USD&gt;</code>  error, where 4200 is total_price for 2 selected products in this case. 42.00 USD.
  this is one more evidence that total_price formula works fine up to the point when the app needs to store it in the database.</p>
  
  <p><strong>Total price:</strong></p>
  
  <p><code>total_price</code> is formed in <strong>cart.rb</strong> and <strong>line_item.rb</strong></p>
  
  <p><strong>line_item.rb</strong></p>
  
  <pre><code>  belongs_to :order
    belongs_to :product
    belongs_to :cart
    belongs_to :user
  
    def total_price
      product.price * quantity
    end
  </code></pre>
  
  <p><strong>cart.rb</strong></p>
  
  <pre><code>has_many :line_items#, :dependent =&gt; :destroy
    has_one :order
  
    def to_s
      id
    end
  
    def add_product(product_id)
      current_item = line_items.find_by_product_id(product_id)
      if current_item
        current_item.quantity += 1
      else
        current_item = line_items.build(:product_id =&gt; product_id)
      end
      current_item
    end
  
    def total_price
      line_items.to_a.sum { |item| item.total_price }
    end
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>the <code>order.total</code> field type in database is now integer(11), but I tried the decimal(10,0) to store the price in cents and it didn't work anyway, I got always total price of 1USD. the price for <code>products</code> are decimal(10,0).</p>
  
  <p>really big <strong>thank you</strong> for helping.. might be useful for future developers that got into this.</p>
  
  <p>Any other information you might need, just let me know.</p>