Overriding a module method from a gem in Rails

A more concise solution: WillPaginate::Finder::ClassMethods.module_eval do def paginate_by_sql sql, options # Your code here end end Put the the code into an initializer file in config/initializers. This is the correct place to put code that needs to be run when the environment is loaded. It also better organises your code, making each file’s intent clearer, … Read more

Ruby on Rails will_paginate an array

will_paginate 3.0 is designed to take advantage of the new ActiveRecord::Relation in Rails 3, so it defines paginate only on relations by default. It can still work with an array, but you have to tell rails to require that part. In a file in your config/initializers (I used will_paginate_array_fix.rb), add this require ‘will_paginate/array’ Then you … Read more