0

I m using kaminari gem
In my events_controller

def show
 ...
 @comments = @event.comments.page(params[:page]).limit(5)
  respond_to do |format|
   format.js
   format.html       
 end
end

in my events/show.html.haml

.row
 .load-more
  = render :partial => 'comments/comment', :collection => @comments, locals: {event_show: true}
  = link_to_next_page @comments, 'Load More', :remote => true, :id=>"load_more_link" 

in my show.js.erb

$('..load-more').append("<%= escape_javascript(render :partial => @comments)%>");
$('#load_more_link').replaceWith("<%= escape_javascript(link_to_next_page(@comments, 'Load More', :remote => true, :id=>'load_more_link'))%>");

Reference SO Answer

I m getting this error

undefined method `last_page?' for <Comment::ActiveRecord_AssociationRelation:0x007fe0931c5860>

in

= link_to_next_page @comments, 'Load More', :remote => true, :id=>"load_more_link" 

Thanks in advance.

Community
  • 1
  • 1
Adt
  • 495
  • 6
  • 19

1 Answers1

2

I found the solution Kaminari have fix for the problem in latest version but it is not working if u have:

gem 'kaminari'

Change it to

gem 'kaminari', :git => 'git@github.com:amatsuda/kaminari.git' 

This will remove the error. Thanks

Adt
  • 495
  • 6
  • 19