Reputation: 79
I am trying to make infinite scrolling but I don't know why it won't work _allposts.html.erb parial
<% @posts.each do |f| %>
<div class="iterate">
<%= f.text %>
<%= f.image %>
</div>
<%= will_paginate @posts %>
posts controller :
class PagesController < ApplicationController
def index
@posts = Post.all.order("created_at DESC").paginate(page: params[:page], per_page: 5)
end
...
end
Upvotes: 2
Views: 3009
Reputation: 7777
For this, you need some ajax
, js
or jQuery
, or coffee
code and some partials, if I will write this then this will very large because you need a full tutorial.
This is a very generic question because you need to follow a deep tutorial for this, you did not write anything for infinite scroll, if you have to try then we have to point out where is the problem, you did not that that's why you follow full tutorial and then apply this then if you will stack for any stage then we will help for this.
Hope it will help
Upvotes: 1
Reputation: 4216
If you are lazy to go making "yourself"(even though a copy paste will work) then you could use this gem
Gemfile
gem 'will_paginate_infinite'
Then run
$ bundle install
Add to app/assets/stylesheets/application.scss
*= require will_paginate_infinite
And javascript to app/assets/javascripts/application.js
//= require will_paginate_infinite
Then use the gem's renderer
<%= will_paginate @posts, renderer: WillPaginateInfinite::InfinitePagination %>
Upvotes: 0