Problem with :include option
-
Chris Wanstrath
- Assigned user changed from Chris Wanstrath to Mislav
- State changed from new to open
-
Mislav
You can help even more. Go to your project and open up Rails console (script/console).
Execute this:
ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveRecord::Base.clear_active_connections!Now perform your stuff that you pasted above. For each "paginate" call perform the "find" equivalent, too. Generated SQL will render in your console; copy and post it here as attachment. Don't forget to indicate was the length expected or not.
When pasting code in your comment, see "formatting help" at the top of comment input box to learn how you can properly paste.
-
atkinw (at rpi)
Output attached. I expect 215 sensors to be returned (both of the Sensor.find calls work correctly here) and I expect both of the paginate calls to return the maximum number of sensors per page (30). The call that returns 28 is the problem.
Here are the interesting parts of the Sensor model:
class Sensor < SensorBase has_many :calibrations, :foreign_key => "associated_sensor", :order => "date DESC" has_one :most_recent_calibration, :class_name => "Calibration", :order => "date DESC", :foreign_key => "associated_sensor" has_many :checkouts belongs_to :current_location, :class_name => "Checkout", :foreign_key => "checkout_id" belongs_to :sensor_type, :foreign_key => "sensor_type" # ... def self.per_page 30 end # ... end -
Mislav
- State changed from open to invalid
Hey, sorry it took so long. I think the issue is because you're specifying 0 for page number, but 1 is first page. In newer versions of will_paginate (since last Christmas), specifying a page number lower than 1 leads to an error being thrown.
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.
