I have a page where a user can enter a message, and subsequently that message will appear below on the page. These messages are intended to be paginated. I am trying to do this with Ajax. Currently my .js.erb file tells the page to re-render a partial in this way:
var submitted_message = $('<%= j(render 'shared/message_listing')%>');
$('#accordion').html(submitted_message);
The message_listing partial contains a pagination statement in it, like this:
<%paginate @messages, :params => { :anchor => "questions" })%>
However, when this line of code renders, the pagination buttons are produced but the url's associated with the links are incorrect. They should look something like
`test.com/client/messages?page=3&pr_rep_id=1047460791&project_id=864121040#questions
On normal page load, the pagination links look like this. Except the pagination urls generated by the ajax request look like this:
client/messages?authenticity_token=ro3YVz%2BnPR4JRC3GL7IVHRYA%2FcEYUjDVp27tDYukm7M%3D&message%5Bpr_rep_id%5D=1047460791&message%5Bproject_id%5D=864121040&message%5Btext%5D=a&page=2&utf8=✓#questions
This link somehow redirects me to an index page. Does anyone know why the pagination generated by the ajax request looks different than it should? All of the pagination links are the same, and it looks like they don't have any page parameter. What can I do to make these links right? Is there a way I can hack up the Kaminari gem that I'm using?
Thanks!
The problem is that I'm using a POST request, in which parameters such as authenticity key are being passed by the kaminari gem. this is similar to this question: