mislav/will_paginate · warning
DEPRECATION WARNING: #{message} (called from #{offending_lin
Error message
DEPRECATION WARNING: #{message} (called from #{offending_line}) What it means
WillPaginate::Deprecation.warn is not a raised exception but the gem's deprecation channel: it formats 'DEPRECATION WARNING: <message> (called from <file:line>)' using origin_of_call(caller) and writes it to Rails.logger when defined, else falls back to Kernel#warn (stderr). Seeing it means the library detected you using an API scheduled for removal and pinpointed the exact call site.
Source
Thrown at lib/will_paginate/deprecation.rb:3
module WillPaginate::Deprecation
class << self
def warn(message, stack = caller)
offending_line = origin_of_call(stack)
full_message = "DEPRECATION WARNING: #{message} (called from #{offending_line})"
logger = rails_logger || Kernel
logger.warn full_message
end
private
def rails_logger
defined?(Rails.logger) && Rails.logger
end
def origin_of_call(stack)
lib_root = File.expand_path('../../..', __FILE__)
stack.find { |line| line.index(lib_root) != 0 } || stack.first
end
end
View on GitHub (pinned to 50017c3eb0)
Solutions
- Open the file:line printed in '(called from ...)' and migrate that call to the replacement named in the message
- Triage in bulk: grep the test suite output for 'DEPRECATION WARNING:' lines mentioning will_paginate and fix each unique call site
- Temporarily silence noise by routing logs, but never ship the deprecated call past the next major upgrade
Example fix
// before
# log: DEPRECATION WARNING: ... (called from app/models/post.rb:8:in `old_style')
class Post < ActiveRecord::Base
def old_style
WillPaginate::Collection.new(1, 10) # deprecated call at post.rb:8
end
end
// after
class Post < ActiveRecord::Base
def old_style
page(1).per(10) # current scope-based API
end
end Defensive patterns
Strategy: validation
Validate before calling
# make deprecations fail specs instead of scrolling past (config/environments/test.rb)
WillPaginate::Deprecation.singleton_class.prepend(Module.new do
def warn(message, stack = caller)
raise "WillPaginate deprecation: #{message} (called from #{WillPaginate::Deprecation.send(:origin_of_call, stack)})"
end
end) Prevention
- Promote will_paginate deprecation warnings to test failures (snippet above) so each one is fixed at the call site it names
- After upgrading will_paginate or Rails, grep logs for 'DEPRECATION WARNING' lines with '(called from ...)' and burn them down before the next major bump
- Pin the gem version in the Gemfile and read its CHANGELOG before upgrading to learn which deprecated APIs become hard errors
When it happens
Trigger: Any library-internal WillPaginate::Deprecation.warn call — typically legacy API usage detected during gem upgrade paths (old option names, removed class methods, changed signatures). The '(called from ...)' suffix names the file and line in your app that triggered it, since caller frames are captured at warn time.
Common situations: Bumping will_paginate after a Rails upgrade and logs flooding with deprecations; CI logs where Kernel fallback prints to stderr because Rails.logger isn't defined yet (e.g., during boot/initializers); teams ignoring warnings until the next major version turns them into hard errors.
Related errors
- :page parameter required
- unsupported parameters: %p
- invalid #{name}: #{value.inspect}
- :renderer not specified
- The #{collection_name} variable appears to be empty. Did you
AI-assisted analysis of mislav/will_paginate@50017c3eb0 (2026-08-21).
Data as JSON: /api/errors/46ab6c01645a17ca.
Report an issue: GitHub.