mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Added pagination for scaffolding (10 items per page) #964 [mortonda@dgrmm.net]
|
||||
|
||||
* Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat]
|
||||
|
||||
* Fixed :overwrite_param so it doesn't delete but reject elements from @request.parameters #982 [raphinou@yahoo.com]
|
||||
|
||||
@@ -166,7 +166,7 @@ module ActionController
|
||||
:find_collection_for_pagination
|
||||
|
||||
def paginator_and_collection_for(collection_id, options) #:nodoc:
|
||||
klass = eval options[:class_name]
|
||||
klass = options[:class_name].constantize
|
||||
page = @params[options[:parameter]]
|
||||
count = count_collection_for_pagination(klass, options[:conditions])
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ module ActionController
|
||||
|
||||
module_eval <<-"end_eval", __FILE__, __LINE__
|
||||
def list#{suffix}
|
||||
@#{plural_name} = #{class_name}.find_all
|
||||
@#{singular_name}_pages, @#{plural_name} = paginate :#{singular_name}, :per_page => 10
|
||||
render#{suffix}_scaffold "list#{suffix}"
|
||||
end
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= link_to "Previous page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous %>
|
||||
<%= link_to "Next page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.next } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.next %>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to "New #{@scaffold_singular_name}", :action => "new#{@scaffold_suffix}" %>
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -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 %>' %>
|
||||
|
||||
Reference in New Issue
Block a user