Forum: Ruby on Rails where to put pagination_by_sql code?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rm R. (Guest)
on 2007-06-01 05:50
I am trying to use the pagination_by_sql explained here :

http://thebogles.com/blog/2006/06/paginate_by_sql-...

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.
This topic is locked and can not be replied to.