2015-10-30 1 views
0

Je suis en utilisant kaminari gem
Dans mon events_controllerméthode non définie `last_page? dans link_to_next_page

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

dans mon 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" 

dans mon 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'))%>"); 

Référence SO Answer

Je ne suis pas à obtenir cette erreur

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

dans

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

Merci à l'avance.

+0

collez votre contrôleur complet s'il vous plaît. – matanco

+0

où votre 'last_page?' Est-elle définie? – sugaryourcoffee

+0

@sugaryourcoffee il n'y a pas last_page? . c'est une méthode fournie par Kaminari – Adt

Répondre

2

J'ai trouvé la solution Kaminari ont correctif pour le problème dans la dernière version, mais il ne fonctionne pas si u ont:

gem 'kaminari' 

Modifier à

gem 'kaminari', :git => '[email protected]:amatsuda/kaminari.git' 

Cela supprimera l'erreur. Merci

+0

cela nécessite une clé SSH "id_rsa" –