aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-02 09:11:17 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-02 09:11:17 +0000
commit3532455404ec8449eee1054e38d1e0db40c63e15 (patch)
tree9db81fad7bd114b723f1cc5d782b412dda15752b /railties
parent5b36c9275d979c40c7e20e9cc0415d4e8dbfd457 (diff)
downloadrails-3532455404ec8449eee1054e38d1e0db40c63e15.tar.gz
rails-3532455404ec8449eee1054e38d1e0db40c63e15.tar.bz2
rails-3532455404ec8449eee1054e38d1e0db40c63e15.zip
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
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml3
2 files changed, 4 insertions, 1 deletions
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 %>
</table>
+<%%= 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 %>
+
<br />
<%%= link_to 'New <%= singular_name %>', :action => 'new<%= suffix %>' %>