开发者

Lazy loading being ignored by activerecord

I found my inherited resources controller is ignoring extra parameters when querying through REST. I did a test replacing the inherited resources method and found out that the model itself is ignoring extra where's.

a = Client.where(:user_id =>开发者_运维问答; 1)
a.where(:project_id => 2)

a.first.project_id == '1'

The second where is being ignored, I see in the log that this is being select:

SELECT "clients".* FROM "clients" WHERE "clients"."user_id" = 1 LIMIT 1


The second a.where is not changing the variable a, so you need to set a again for the second where clause:

a = Client.where(:user_id => 1)
a = a.where(:project_id => 2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜