简体   繁体   中英

How would I query a query in ruby on rails?

I have a query as follows:

events = Event.joins(:user_events).where(:user_events => { :user => user }).by_time(time)

How would I go about creating a query to find a specific object in this query?

The events object is ActiveRecord::Relation object, which means it's chainable.

You can further call another condition based on it.

event = events.where(id: 123)

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