Created
February 25, 2014 12:40
-
-
Save madzhuga/9208075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
search_scope = Delivery.accessible_by(current_ability, :read) | |
search_scope = search_scope.where(state: :quotation_request). | |
joins(" inner join (select * from (select *, max(id) over (partition by delivery_id) from quotation_requests)t where t.max = t.id)tt on tt.delivery_id = deliveries.id "). | |
includes(:quotation_requests). | |
where(quotation_requests: {status: params[:q][:status_in].select(&:present?) }) | |
search_scope = search_scope.search(params[:q]) | |
search_scope = search_scope.order("quotation_requests.id DESC") | |
set_collection_ivar(search_scope.paginate(page: params[:page], per_page: 20)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment