class Author belongs_to :book end
class Book < ActiveRecord::Base has_one :sales_data has_many :authors end
class SalesData < ActiveRecord::Base belongs_to :book end
What code would be required to directly find the Authors from the SalesData? i.e. in SQL: SELECT SUM(sales_data.price), authors.name FROM sales_data LEFT JOIN authors ON sales_data.book_id = authors.book_id GROUP BY authors.name
I know I could use find_by_sql ... just looking for something a little cleaner - has_many(:through) doesn't seem to work. Is this a bug in has_many :through or am I just using it wrong?