简体   繁体   中英

rails 3.0.1 active_record

How is it possible with active_record?

u = User.all
u = u.where(:id => 1)

NoMethodError: undefined method `where' for # u.class => Array

Can't chain conditions :(

The all method executes the query. So you can't chain after using it.

u = User.where(:id => 1)
u.where(:id => 2)

This would execute the query WHERE id = 1 AND id = 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM