ActiveRecord::StatementInvalid when using custom select and having
-
Mislav
- State changed from new to open
- Assigned user changed from Chris Wanstrath to Mislav
Hey asherwood,
Indeed, you can provide your own count:
@results = Page.paginate :all, :select => "...", :group => 'pages.id HAVING distance < 300', :page => params[:page], :per_page => 5, :total_entries => Page.count(...)Observe the last parameter. When you provide :total_entries, will_paginate is going to use that and never perform a count by itself.
-
Mislav
- State changed from open to invalid
- Tag set to will_paginate
-
Greg
untested hack that can be added to wp_count in will_paginate/lib/will_paginate/finder.rb to generate proper SQL.
if count_options[:group] and count_options[:group] =~ /(.*)having/i count_options[:group] = $1 end
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.