Thursday, 8 August 2019

Top count in views



@tabs = Tab.select("tabs.*, COUNT(views.id) something_variable").joins(:views).where('views.created_at between ? and ?', Time.now - 1.week, Time.now).group("tabs.id").order("something_variable DESC").paginate(page: page,per_page: 200)