Reputation: 645
I'm using will paginate on my ruby on rails app..I've used this before on other apps and it was working fine however when i used it on this one for some reason it looks like the tabs for the pagination are reversed.
Here's the html
<div class="container">
<br />
<br />
<h2 class="black">
Recent News
<div class="line_section"><div>
</h2>
<div class="row">
<div class="span12">
<ul class="recent-news">
<% @news_all.each do |news| %>
<li style="font-size: 16px; line-height: 19px; letter-spacing: 1px; font-size: 14px; color: #555; text-align: left;">
<%= image_tag news.photo.url, class: 'pull-left', style: 'margin-right:40px; margin-top: 2px; width: 300px;' %>
<div style=" width: 600px; float: right;">
<%= link_to news.title, news %>
<br />
<%= link_to news.date, news, style: 'font-size: 10px; color: black; position: relative; top: 15px;' %>
<br /><br />
<%= truncate news.content, length: 500 %>
<br />
<%= link_to 'Read More...', news, style: 'font-size: 12px !important;' %>
</div>
</li>
<% end %>
<%= will_paginate @news_all %>
</div><!-- end span12 -->
</div><!-- end row -->
</div><!-- end container -->
here's the controller
def batnews
@article = Article.first
@news_all = News.all
@news_all = News.paginate(page: params[:page]).limit(4)
@comments = Comment.all
end
here's the link to the site so you can see what's actually going on.
http://www.batman-fansite.com/batnews
if you scroll to the way bottom you will see the pagination.
Upvotes: 1
Views: 107
Reputation: 11
Try something like this:
def index
@posts = Post.paginate :page => params[:page], **:order => "created_at ASC"**
end
Upvotes: 0
Reputation: 19145
There are two problems here:
Check your CSS, you'll find:
.recent-news li {
float: right;
}
...and your controller code should be:
@news_all = News.paginate(page: params[:page], per_page: 4)
Upvotes: 1
Reputation: 12818
Fix you css:
.recent-news li {
float: right;
}
add something like
.recent-news .pagination li {
float: left;
}
Upvotes: 1