Get SQL for activerecord conditions without main select

时间:2015-10-29 15:54:53

标签: ruby-on-rails activerecord

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'

1 个答案:

答案 0 :(得分:0)

我认为你想要范围:
您可以在此处找到有关范围的更多信息: http://guides.rubyonrails.org/active_record_querying.html#scopes