# Globalizing Currency... last line

**URL:** <https://www.ruby-forum.com/t/globalizing-currency-last-line/96896>\
**Category:** Rails I18n\
**Created:** [July 3, 2006, 7:38am UTC](https://www.ruby-forum.com/t/globalizing-currency-last-line/96896 "2006-07-03T07:38:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 3, 2006, 7:38am UTC](https://www.ruby-forum.com/t/globalizing-currency-last-line/96896/1 "2006-07-03T07:38:34Z")

</div>

it’s quite running smoothly… at least I get correct prices in  
local format…

but I cannot yet create or update it :

my Product model is defined as following :

class Product \< ActiveRecord::Base

composed\_of :price, :class\_name =\> “Globalize::Currency”, :mapping  
=\> [%w(price cents)]

attr\_accessor :lp #not stored in DB, used to display formatted  
price in form

the form as following :

Prix (en euros)  
\<%= text\_field 'product', 'lp' %\>

and the controller

def new  
@product = Product.new  
@product.price = Currency.parse(0).format  
end

def create  
@product = Product.new(@params[:product])  
if @product.save  
…

def edit  
@product = Product.find(@params[:id])  
@product.lp = @product.price.format  
end

def update  
@product = Product.find(@params[:id])  
@product.price = Currency.parse(@params[:lp])  
if @product.update\_attributes(@params[:product])  
…  
else  
render\_action ‘edit’  
end  
end

when trying to create a new Product  
I get the message : undefined method `cents’ for “0,00 â?¬”:String

when modifying an existing price in DB  
… there is no update !

what’s wrong… ??

thanks

kad
