has_one :through

March 24, 2008

Finally we will be able to refactor our ugly code when we have this situation (changeset 9067):

class User < ActiveRecord::Base
  has_many :channels
end
class Channel < ActiveRecord::Base
  belongs_to :network
  belongs_to :user
end
class Group < ActiveRecord::Base
  has_many :channels
  has_one :network,
    :through => :channels,
    :conditions => ['channels.alive? = ?', true]
end

Another good news is that the RubyForge place for the OTS project was finally approved. So guess I will be doing some work on it this afternoon.

Leave a Reply