Where to put pagination_by_sql code?


#1

I am trying to use the pagination_by_sql explained here :

http://thebogles.com/blog/2006/06/paginate_by_sql-for-rails-a-more-general-approach/

Now I don’t know where to put the following code sso that all the models
could use it.

module ActiveRecord
class Base
def self.find_by_sql_with_limit(sql, offset, limit)
sql = sanitize_sql(sql)
add_limit!(sql, {:limit => limit, :offset => offset})
find_by_sql(sql)
end

    def self.count_by_sql_wrapping_select_query(sql)
        sql = sanitize_sql(sql)
        count_by_sql("select count(*) from (#{sql}) as my_table")
    end

end
end

But I can’t figure out where the code for ActiveRecord would go? Where
is the activerrecord base class in the directory structure to modify?

Thanks.