views:

23

answers:

0

I have following database schema:

alt text

I want to be able to do something like this:

dog.head << Feature.new(...)
dog.tail << Feature.new(...)

I am new to Rails, so I am not always sure by 100% what I am writing, but I tried following declaration of Dog class, and failed :) :

class Dog < ActiveRecord::Base
  has_many :features, :through=>:dog_features
  has_many :head_features, :through=>:dog_features, :class_name=>'Feature', :conditions=>{:group=>1}
  has_many :tail_features, :through=>:dog_features, :class_name=>'Feature', :conditions=>{:group=>2}
end