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

On 03/04/2013, Colin Law <clan...@googlemail.com> wrote:
> On 3 April 2013 20:58, John Merlino <stoici...@aol.com> wrote:
>> 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?
>
> Can you show us the code where you perform the test that is failing?
>
> Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to