Permalink
Browse files

added pagination and raw descriptions

  • Loading branch information...
chrismatthieu committed Aug 7, 2011
1 parent 1dece73 commit b445b70feb18dc6bc06646cf3ce43243bea06df0
View
@@ -2,6 +2,8 @@ source 'http://rubygems.org'
gem 'rails', '3.1.0.rc5'
+gem "will_paginate", :git => "https://github.com/p7r/will_paginate.git", :branch => "rails3"
+
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
View
@@ -1,3 +1,10 @@
+GIT
+ remote: https://github.com/p7r/will_paginate.git
+ revision: 53d1da6da003dc172ee054e4cc416d0723f00b88
+ branch: rails3
+ specs:
+ will_paginate (3.0.pre3)
+
GEM
remote: http://rubygems.org/
specs:
@@ -102,3 +109,4 @@ DEPENDENCIES
pg
rails (= 3.1.0.rc5)
sass-rails (~> 3.1.0.rc)
+ will_paginate!
@@ -5,7 +5,9 @@ class PodcastsController < ApplicationController
# GET /podcasts
# GET /podcasts.json
def index
- @podcasts = Podcast.order("created_at DESC")
+ # @podcasts = Podcast.order("created_at DESC")
+ # @podcasts = Podcast.all :page => params[:page], :order => 'created_at DESC'
+ @podcasts = Podcast.paginate :page => params[:page], :per_page => 3, :order => 'created_at DESC'
respond_to do |format|
format.html # index.html.erb
View
@@ -1,2 +1,5 @@
class Podcast < ActiveRecord::Base
+ def self.per_page
+ 3
+ end
end
@@ -32,7 +32,7 @@
<% end %>
- <p><%= podcast.poddesc %></p>
+ <p><%= raw(podcast.poddesc) %></p>
<% if @current_user && @current_user.admin %>
<p><%= link_to 'Edit', :action => 'edit', :id => podcast %> | <%= link_to 'Destroy', { :action => 'destroy', :id => podcast }, :confirm => 'Are you sure?', :method => :podcast %></p>
@@ -42,6 +42,10 @@
<% end %>
+<div class="entry">
+<%= will_paginate @podcasts %>
+</div>
+
<%# link_to 'Previous page', { :page => @podcast_pages.current.previous } if @podcast_pages.current.previous %>
<%# link_to 'Next page', { :page => @podcast_pages.current.next } if @podcast_pages.current.next %>
@@ -34,7 +34,7 @@
<% end %>
- <p><%= @podcast.poddesc %></p>
+ <p><%= raw(@podcast.poddesc) %></p>
<% if @current_user && @current_user.admin %>
<p><%= link_to 'Edit', :action => 'edit', :id => @podcast %> | <%= link_to 'Destroy', { :action => 'destroy', :id => @podcast }, :confirm => 'Are you sure?', :method => :podcast %></p>

0 comments on commit b445b70

Please sign in to comment.