This project is archived and is in readonly mode.

#1229 ✓committed
John Wulff

Add :from scoping respect to Calculations module

Reported by John Wulff | October 16th, 2008 @ 11:43 PM | in 2.3.4

Calculations do not respect :from scopings. (The do now respect :from as an option.)


class Node < ActiveRecord::Base
  named_scope :old_nodes, { :from => 'old_nodes' }
end

Node.old_nodes.average(:value)

executes:


SELECT avg("nodes".value) AS avg_value FROM "nodes"

it should respect the scope and execute:


SELECT avg("nodes".value) AS avg_value FROM "old_nodes"

I've attached a fix.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages