I am developing a project with rails 3.1.3 and kaminari 0.13.0. I have two models Article and Comment. Article has many Comments. My controllers are ArticlesController which basically does everything except for creating comments. This is handled by CommentsController. In my view for 'articles#show' I have a form to crate new comments. I want this form to be submitted remotely (:remote => true). I have a list of comments right bellow it which is paginated with kaminari. Naturally, I want the list to be refreshed. However as the comment is submitted to 'comments#create', the pagination links become incorrect when rerendered. I tried to add <%= paginate @comments, :params => { :controller => "articles", :action => 'show' } %> to make them point to the right url, however this didn't solve my problem. When the list is rerendered, I receive:
ActionView::Template::Error (No route matches
{:utf8=>"✓",:authenticity_token=>"5VJqDLifXX0O/ttq9rNY0POUbsN678I6Au2iL2Qcv7w=",
:comment=>{"name"=>"4004053","content"=>"asdf"},:commit=>"Create Comment",
:action=>"show",:controller=>"articles",:article_id=>"4f24fbb4f4b7b863a4000009",
:page=>nil}):
I can solve this by adding extra attribute to paginate and make it <%= paginate @comments, :custom_url => "/articles/#{@article._id}" %>. Then I can change kaminari's views to set the url to my custom_url if it is there. However I don't like very much the idea.
Am I missing something? Is there a better way to do this?
Thank you in advance!