{"record":{"id":"46ab6c01645a17ca","repo":"mislav/will_paginate","slug":"deprecation-warning-message-called-from-off","errorCode":null,"errorMessage":"DEPRECATION WARNING: #{message} (called from #{offending_line})","messagePattern":"DEPRECATION WARNING: #(.+?) \\(called from #(.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/will_paginate/deprecation.rb","lineNumber":3,"sourceCode":"module WillPaginate::Deprecation\n  class << self\n    def warn(message, stack = caller)\n      offending_line = origin_of_call(stack)\n      full_message = \"DEPRECATION WARNING: #{message} (called from #{offending_line})\"\n      logger = rails_logger || Kernel\n      logger.warn full_message\n    end\n\n    private\n\n    def rails_logger\n      defined?(Rails.logger) && Rails.logger\n    end\n\n    def origin_of_call(stack)\n      lib_root = File.expand_path('../../..', __FILE__)\n      stack.find { |line| line.index(lib_root) != 0 } || stack.first\n    end\n  end\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/mislav/will_paginate/blob/50017c3eb0712e7b3a53268a81e81a184b7a49f6/lib/will_paginate/deprecation.rb#L1-L21","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n# log: DEPRECATION WARNING: ... (called from app/models/post.rb:8:in `old_style')\nclass Post < ActiveRecord::Base\n  def old_style\n    WillPaginate::Collection.new(1, 10) # deprecated call at post.rb:8\n  end\nend\n\n// after\nclass Post < ActiveRecord::Base\n  def old_style\n    page(1).per(10) # current scope-based API\n  end\nend","handlingStrategy":"validation","validationCode":"# make deprecations fail specs instead of scrolling past (config/environments/test.rb)\nWillPaginate::Deprecation.singleton_class.prepend(Module.new do\n  def warn(message, stack = caller)\n    raise \"WillPaginate deprecation: #{message} (called from #{WillPaginate::Deprecation.send(:origin_of_call, stack)})\"\n  end\nend)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["will-paginate","deprecation","logging","upgrade"],"backgroundTag":"deprecation-warning","analyzedSha":"50017c3eb0712e7b3a53268a81e81a184b7a49f6","analyzedAt":"2026-08-21T19:50:58.546Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}