{"record":{"id":"8431af4acdc36f41","repo":"mislav/will_paginate","slug":"unsupported-parameters-p","errorCode":null,"errorMessage":"unsupported parameters: %p","messagePattern":"unsupported parameters: %p","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/will_paginate/active_record.rb","lineNumber":151,"sourceCode":"      private\n\n      def copy_will_paginate_data(other)\n        other.current_page = current_page unless other.current_page\n        other.total_entries = nil if defined? @total_entries_queried\n        other\n      end\n    end\n\n    module Pagination\n      def paginate(options)\n        options  = options.dup\n        pagenum  = options.fetch(:page) { raise ArgumentError, \":page parameter required\" }\n        options.delete(:page)\n        per_page = options.delete(:per_page) || self.per_page\n        total    = options.delete(:total_entries)\n\n        if options.any?\n          raise ArgumentError, \"unsupported parameters: %p\" % options.keys\n        end\n\n        rel = limit(per_page.to_i).page(pagenum)\n        rel.total_entries = total.to_i          unless total.blank?\n        rel\n      end\n\n      def page(num)\n        rel = if ::ActiveRecord::Relation === self\n          self\n        elsif !defined?(::ActiveRecord::Scoping) or ::ActiveRecord::Scoping::ClassMethods.method_defined? :with_scope\n          # Active Record 3\n          scoped\n        else\n          # Active Record 4\n          all\n        end\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/active_record.rb#L133-L169","documentation":"will_paginate's paginate() only consumes exactly three keys: :page, :per_page and :total_entries. After deleting those from a dup of the options hash, any remaining key makes it raise ArgumentError 'unsupported parameters: %p' formatted with the leftover keys. This is a hard rejection of old Active Record 2.x finder options (:conditions, :order, :include, :joins, :limit...) which AR3+ scopes replaced.","triggerScenarios":"Model.paginate(page: 1, conditions: ['salary > ?', 80000]), .paginate(:page => 1, :order => 'created_at DESC'), or any paginate call whose hash still carries :include/:joins/:limit/:offset/:readonly or a typo'd key like :perpage. The message body will literally list the offending keys.","commonSituations":"Upgrading an app from Rails 2 / will_paginate 2.x, where finder options inside paginate were legal; copy-pasting pre-2010 pagination snippets; merging an options hash built for Model.find into paginate; fat-fingered keys that no longer fail silently.","solutions":["Move every non-pagination option into the scope chain before paginate: Model.where('salary > ?', 80000).order('created_at DESC').paginate(page: 1, per_page: 10)","Read the %p list in the message and delete/rename each listed key (e.g. :perpage -> :per_page)","If the hash is dynamic, whitelist it first: options.slice!(:page, :per_page, :total_entries)"],"exampleFix":"// before\n@developers = Developer.paginate(page: params[:page], conditions: ['salary > ?', 80000], order: 'name')\n\n// after\n@developers = Developer.where('salary > ?', 80000).order('name').paginate(page: params[:page] || 1, per_page: 10)","handlingStrategy":"validation","validationCode":"ALLOWED = %i[page per_page total_entries].freeze\nextras = options.symbolize_keys.keys - ALLOWED\nraise ArgumentError, \"unsupported parameters: #{extras.inspect}\" unless extras.empty?\nModel.where(...).paginate(options)","typeGuard":null,"tryCatchPattern":"begin\n  relation.paginate(options)\nrescue ArgumentError => e\n  raise unless e.message.start_with?('unsupported parameters')\n  # log the listed keys, then rebuild the call with scopes instead of finder options\n  raise\nend","preventionTips":["Never forward arbitrary params hashes into paginate; always slice to :page/:per_page/:total_entries","Treat finder options inside paginate as a Rails-2 smell in review: conditions/order/joins belong in the scope chain","During Rails 2 -> 3+ upgrades, grep for 'paginate(' and audit each options hash with the whitelist above"],"tags":["will-paginate","activerecord","rails-upgrade","pagination"],"backgroundTag":"unsupported-option-key","analyzedSha":"50017c3eb0712e7b3a53268a81e81a184b7a49f6","analyzedAt":"2026-08-21T19:50:58.546Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}