I am using paginate to get the list of events from my database. Besides pagination I also want to display the total number of records.
I noticed that the paginate query inside does do a SQL query to get the total numbe of records. Is there a way to tap that count rather than having a separate query to just to get the count of records.
My existing pagination query is given below.
@query_join = "JOIN venues ON [venues.id](http://venues.id) = events.venue_id " @query_join << "JOIN cities ON [
cities.id](http://cities.id) = venues.city_id"
@event_pages, @events = paginate :events,
:joins => @query_join,
:conditions => ["start_date > ? ",Time.now],
:per_page => per_page,
:order => :start_date, :select => "events.*"
The generate query in the log: