Is there any way to get the sql for a single condition or chain of conditions so Booking.where(active: true).to_conditional_sql
would return WHERE bookings.active='t'
instead of SELECT * FROM bookings WHERE bookings.active='t'
答案 0 :(得分:0)
我认为你想要范围:
您可以在此处找到有关范围的更多信息:
http://guides.rubyonrails.org/active_record_querying.html#scopes