paginate the class
Posted
by small
on Stack Overflow
See other posts from Stack Overflow
or by small
Published on 2010-03-23T14:39:00Z
Indexed on
2010/03/23
16:03 UTC
Read the original article
Hit count: 183
ruby-on-rails
please help me with pagination of this method
my method is this one
controller
#def show
@topic = Topic.find(params[:id])
@posts = @topic.posts.find(:all ,:order=> 'id')
end
views
#%div{:style=>"margin: 0 auto;"}
%table.sortable.style2{:cellpadding=>5}
%thead
%tr
%td{:width => "25%",:align => "center",:style => "font-weight: bold;"}Posted By
%td{:width => "75%",:style => "font-weight: bold;"}Comments
%tbody
- for post in @posts
%tr
%td{:align => "center"}
 
%div{:width=>"5px" , :style=>"border: 1px solid rgb(232, 232, 232);background-color: rgb(248, 248, 248);width: 60px; height:60px;" }
- if post.posted_by.image
= image_tag(post.posted_by.image.public_filename(),:width => "60px", :height => "60px",:align=>"center")
%div{:style => "font-weight: bold; font-style: italic;"}
= post.posted_by ? post.posted_by.firstname : "<em>Unknown User</em>"
%br
%div{:style => "font-style: italic;"}
Posted on
= post.created_at.strftime('%d of %B %Y ')
= post.created_at.strftime('at %H:%M')
%td{:valign => "top"}
=post.body
© Stack Overflow or respective owner