fwiw, this works.
module ActiveRecord
class Base
def self.find_by_sql_with_limit(sql, offset, limit)
sql = sanitize_sql(sql)
find_by_sql(sql + " LIMIT #{offset},#{limit}")
end
def self.count_by_sql_wrapping_select_query(sql)
sql = sanitize_sql(sql)
count_by_sql("select count(*) from (#{sql}) as x")
end
end
end
On Jun 30, 10:23 am, Obelix
<anand.sanka...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I am trying to port an existing rails app running rails 2.3.8 to
> 3.0.0beta4
>
> I use this paginate_by_sql hack
>
> 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 x")
> end
> end
> end
>
> The add_limit! method has been removed from ActiveRecord::Base class.
> Are there any work arounds for this? Any alternatives to doing
> pagination by SQL in Rails 3.0.0?
>
> Thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.