【发布时间】:2017-12-05 14:23:48
【问题描述】:
我有这个问题:
includes(:foo).where(foo: { price: 0 })
我从一个名为 Recipe 的类中调用它。
Foo 有十进制类型列price:
>> Recipe.first.foo
=> #<Foo id: 1, price: #<BigDecimal:928b000,'0.0',9(18)>, slug: "something", created_at: "2017-12-05 07:54:29", updated_at: "2017-12-05 13:00:51">
我收到此错误:
Mysql2::Error: 'where 子句'中的未知列 'foo.price': SELECT
recipes.idAS t0_r0,recipes.foo_idAS t0_r1,recipes.parent_recipe_idAS t0_r2,recipes987654332 @为t0_r3,recipes987654334 @作为t0_r4,quantities987654336 @作为t0_r5,recipes987654338 @作为t0_r6,quantities987654339 @ 987654340 t0_r7,foos987654342 @为t1_r0,foos987654344 @作为t1_r1,foos987654346 @作为t1_r2,foos987654347foos987654350 @created_att1_r4,foos。updated_atAS t1_r5 FROMrecipesLEFT OUTER JOINfoosONfoos。id=recipes。foo_idWHEREfoo。price= 0.0 p >
为什么这不起作用?我正在使用其他一切正常的查询。
【问题讨论】:
-
@mudasobwa 给了我同样的错误减去 globalize gem 的东西。
标签: mysql sql ruby-on-rails ruby activerecord