From 87b68002827015d887dd566c477b957d8e5cb842 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 31 Aug 2005 00:13:10 +0000 Subject: 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 --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/pagination.rb | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index f885ec3508..9ff0ca0cb2 100644 --- a/actionpack/CHANGELOG +++ b/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. diff --git a/actionpack/lib/action_controller/pagination.rb b/actionpack/lib/action_controller/pagination.rb index a3e8f36d70..709b56bfba 100644 --- a/actionpack/lib/action_controller/pagination.rb +++ b/actionpack/lib/action_controller/pagination.rb @@ -63,6 +63,7 @@ module ActionController # 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 @@ module ActionController "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 @@ module ActionController # ClassMethods#paginate. # # +options+ are: - # :class_name:: the class name to use, if it can't be inferred by + # :singular_name:: the singular name to use, if it can't be inferred by # singularizing the collection name + # :class_name:: the class name to use, if it can't be inferred by + # camelizing the singular name # :per_page:: the maximum number of items to include in a # single page. Defaults to 10 # :conditions:: optional conditions passed to Model.find(:all, *params) and -- cgit v1.2.3