Permalink
Browse files

Add option to specify the singular name used by pagination. Closes #1960



git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2078 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 34e795f commit 87b68002827015d887dd566c477b957d8e5cb842 @seckar seckar committed Aug 31, 2005
Showing with 7 additions and 2 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +5 −2 actionpack/lib/action_controller/pagination.rb
@@ -1,5 +1,7 @@
*SVN*
+* Add option to specify the singular name used by pagination.
+
* Use string key to obtain action value. Allows indifferent hashes to be disabled.
* Added ActionView::Base.cache_template_loading back.
@@ -63,6 +63,7 @@ module Pagination
# The default options for pagination
DEFAULT_OPTIONS = {
:class_name => nil,
+ :singular_name => nil,
:per_page => 10,
:conditions => nil,
:order_by => nil,
@@ -91,7 +92,7 @@ def self.validate_options!(collection_id, options, in_action) #:nodoc:
"Unknown options: #{unknown_option_keys.join(', ')}" unless
unknown_option_keys.empty?
- options[:singular_name] = Inflector.singularize(collection_id.to_s)
+ options[:singular_name] ||= Inflector.singularize(collection_id.to_s)
options[:class_name] ||= Inflector.camelize(options[:singular_name])
end
@@ -101,8 +102,10 @@ def self.validate_options!(collection_id, options, in_action) #:nodoc:
# ClassMethods#paginate.
#
# +options+ are:
- # <tt>:class_name</tt>:: the class name to use, if it can't be inferred by
+ # <tt>:singular_name</tt>:: the singular name to use, if it can't be inferred by
# singularizing the collection name
+ # <tt>:class_name</tt>:: the class name to use, if it can't be inferred by
+ # camelizing the singular name
# <tt>:per_page</tt>:: the maximum number of items to include in a
# single page. Defaults to 10
# <tt>:conditions</tt>:: optional conditions passed to Model.find(:all, *params) and

0 comments on commit 87b6800

Please sign in to comment.