Strange behavior with active relation any? method

In console, I run the following and any? returns true:
drivers = Driver.select(“drivers.*,
drivers.id”).joins([:reports, :driving_habits]).where(“extract(MONTH
FROM reports.time) = ? AND extract(YEAR FROM reports.time) = ?”, 3,
2013).uniq.order(“drivers.id asc”).page(2).per(1)
drivers.any?
=> true

This correctly evaluates to true because the relation contains one
returned record.

However, I run the same query within the Rails app itself, and any?
must evaluate @drivers in the view to either false or nil, because the
else is triggered instead when I click on second page in view. What’s
even weirder is that when I call inspect on @drivers, then
@drivers.any? is evaluated to true in the view when I click on the
second page using kaminari:

@drivers = Driver.select("drivers.*, #{sort_column}")
                .joins([:reports, :driving_habits])
                .by_month(for_selected_month.to_i,

for_selected_year.to_i)
.order(sort_column + " " + sort_direction)
.page(params[:page]).per(1)

puts "The drivers #{@drivers.inspect}"

What’s driving all this weird behavior?

On 3 April 2013 20:58, John M. [email protected] wrote:

for_selected_year.to_i)
.order(sort_column + " " + sort_direction)
.page(params[:page]).per(1)

puts "The drivers #{@drivers.inspect}"

What’s driving all this weird behavior?

Can you show us the code where you perform the test that is failing?

Colin

hola por favor yo quiero baja rubyonrails-talk este ymail gracias