Forum: Ruby on Rails active_record postgresql adapter problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James B. (Guest)
on 2006-03-01 19:19
Instead of using numeric I created the field "unit_price" as PostgreSQL
type money.  Now when I try and add a row I get the following.  How do I
override AR default behaviour to cast numeric post data to money, or am
I forced to only support database types that active_record knows about?

RuntimeError: ERROR	C42804	Mcolumn "unit_price" is of type money but
expression is of type numeric	HYou will need to rewrite or cast the
expression.	Fparse_target.c	L361	RupdateTargetListEntry: INSERT INTO
line_items ("order_id", "product_id", "quantity", "unit_price")
VALUES(1, 3, 1.0, 5367829.95)

Regards,
Jim
Jeremy K. (Guest)
on 2006-03-01 19:22
(Received via mailing list)
On Mar 1, 2006, at 9:19 AM, James B. wrote:
> expression is of type numeric	HYou will need to rewrite or cast the
> expression.	Fparse_target.c	L361	RupdateTargetListEntry: INSERT INTO
> line_items ("order_id", "product_id", "quantity", "unit_price")
> VALUES(1, 3, 1.0, 5367829.95)

MONEY is deprecated. You work with it as a string, not a number.

Use NUMERIC instead.

Best,
jeremy
James B. (Guest)
on 2006-03-01 19:45
Jeremy K. wrote:
> On Mar 1, 2006, at 9:19 AM, James B. wrote:

> MONEY is deprecated. You work with it as a string, not a number.
>
> Use NUMERIC instead.
>
> Best,
> jeremy

Done, Works, Thanks.

Jim
This topic is locked and can not be replied to.