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.