?", some_other_money_item) Any ideas? PG::UndefinedColumn: ERROR: column "mone" /> ?", some_other_money_item) Any ideas? PG::UndefinedColumn: ERROR: column "mone" /> ?", some_other_money_item) Any ideas? PG::UndefinedColumn: ERROR: column "mone"/>

Return results from money (ruby) with a comparison (e.g. items more than x)

256 Views Asked by At

Pretty simple one.

I want to do the following

Model.where("money_rate > ?", some_other_money_item)

Any ideas?

PG::UndefinedColumn: ERROR:  column "money_rate" does not exist
LINE 1: SELECT "jobs".* FROM "jobs"  WHERE (money_rate > '--- !ruby/...etc
1

There are 1 best solutions below

0
Carpela On BEST ANSWER

Seems that you can only do a comparison using the base method, in the above case this would be money_rate_cents

So:

Model.where("money_rate_cents > ?", some_other_money_item_in_cents)

Returns an array of items where the money attribute is higher.

Will leave that in case someone else finds it useful. Or in case I'm missing something and you can do comparisons on the whole number.