Current result: In deadline filter, it is considering the first box as "from date " and the second as "to date" and on applying the filter same tickets are repeating Expected result: The deadline filter should work properly and on applying the filter tickets should not repeat View:-
<div>
<div >
<div >
<label>Deadline Date</label>
<div >
<%= f.date_field :developers_deadline_date_gteq, class:"fa fa-calendar form-control", id: "todate-form" %>
<%= image_tag("datepickerArrow.svg", alt: "image is not loaded", class:"date-img") %>
<%= f.date_field :developers_deadline_date_lteq, class:"fa fa-calendar form-control", id: "fromdate-form" %>
</div>
</div>
</div>
</div>
Controller:-
@q = ClientRequest.with_resource_info_and_developer.page(params[:page]).per(params[:per_page]).ransack(params[:q])
@client_requests = @q.result
What am I doing wrong? I suspect it's got something to do with the way I'm passing params to Ransack but I don't see why it wouldn't work.
Any help is appreciated.
CodePudding user response:
Database JOINs can lead to duplicate results, depending on the type of relation between both tables and the conditions run.
Just add distinct
to your query to tell Ruby on Rails to only return unique records:
@q = ClientRequest
.with_resource_info_and_developer
.page(params[:page])
.per(params[:per_page])
.ransack(params[:q])
.distinct