From 3532455404ec8449eee1054e38d1e0db40c63e15 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 2 Apr 2005 09:11:17 +0000 Subject: Added pagination for scaffolding (10 items per page) #964 [mortonda@dgrmm.net] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1067 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../generators/components/scaffold/templates/controller.rb | 2 +- .../generators/components/scaffold/templates/view_list.rhtml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails_generator') diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb index b3190918bd..4959674976 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb @@ -12,7 +12,7 @@ class <%= controller_class_name %>Controller < ApplicationController <% end -%> def list<%= suffix %> - @<%= plural_name %> = <%= model_name %>.find_all + @<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= singular_name %>, :per_page => 10 end def show<%= suffix %> diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml b/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml index 0ca1d1c97e..f30772b41b 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml @@ -19,6 +19,9 @@ <%% end %> +<%%= link_to "Previous page", { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %> +<%%= link_to "Next page", { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %> +
<%%= link_to 'New <%= singular_name %>', :action => 'new<%= suffix %>' %> -- cgit v1.2.3