Skip to content

Commit

Permalink
Add option to specify the singular name used by pagination. Closes #1960
Browse files Browse the repository at this point in the history


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2078 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Aug 31, 2005
1 parent 34e795f commit 87b6800
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -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.
Expand Down
7 changes: 5 additions & 2 deletions actionpack/lib/action_controller/pagination.rb
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 87b6800

Please sign in to comment.