I have two models, History and SalesOrder, which are setup like this: class History < ActiveRecord::Base belongs_to :sales_order end class SalesOrder < ActiveRecord::Base has_many :histories has_many :latest_history, :class_name => "History", :order => "id desc" end Is it possible to use a where clause when finding SalesOrders that is based on History? For example: orders = SalesOrder.find(:all, :order => 'latest_history asc') Is that kind of thing even possible with Active Record?
on 2007-04-03 21:45
on 2007-04-04 00:59
I think you want to pass has_many a block with your conditions... Read about it here: http://api.rubyonrails.org/classes/ActiveRecord/As... b