I have a pagination on a page using Kaminari and Ajax, but actually, when I click 'next' button or a number of the pagination, I haven't result and the url is doesn't updated. If I click on '2' I want my url being :
'localhost:3000/auto-ecoles/paris/paris/gp-conduite?filter=verified&page=2'
and right now if I click on '2', the content of my div disappear and my url is :
'localhost:3000/auto-ecoles/paris/paris/gp-conduite?filter=verified'
If write by my self the good url it work so, something went wrong !
here is the code, controller :
if !params[:filter] || params[:filter] == "verified"
@models = @school.ratings.verified.page(params[:page]).per(15)
elsif params[:filter] == "unverified"
@models = @school.ratings.unverified.page(params[:page]).per(15)
elsif params[:filter] == "allratings"
@models = @school.ratings.page(params[:page]).per(15)
end
respond_to :html, :js
View :
<div class="vv-tab-menu">
<%= link_to 'Avis vérifiés', specific_school_path(filter: "verified") %>
<%= link_to 'Avis non-vérifiés', specific_school_path(filter: "unverified") %>
<%= link_to 'Tous les avis', specific_school_path(filter: "allratings") %>
</div>
<div class="vv-tab-content">
<%= render partial: 'schools/rating', collection: @models %>
<%= paginate @models, params: params, :remote => true %>
</div>
and js.erb file
<% if !params[:filter] || params[:filter] == "verified" %>
$('.vv-tab-content').html('<%= escape_javascript render(partial: "schools/rating", collection: @models) %>');
$('.vv-tab-content').html('<%= escape_javascript(paginate(@models, params: params, :remote => true).to_s) %>');
<% elsif params[:filter] == "unverified" %>
$('.vv-tab-content').html('<%= escape_javascript render(partial: "schools/rating", collection: @models) %>');
$('.vv-tab-content').html('<%= escape_javascript(paginate(@models, params: params, :remote => true).to_s) %>');
<% elsif params[:filter] == "allratings" %>
$('.vv-tab-content').html('<%= escape_javascript render(partial: "schools/rating", collection: @models) %>');
$('.vv-tab-content').html('<%= escape_javascript(paginate(@models, params: params, :remote => true).to_s) %>');
<% end %>
Do you know how to pass the page number in my url, using Ajax ? Does something is wrong in my code ?