Here''s the setup (working off Rails 1.1.4): Class Project belongs_to :employee Class Employee < Person has_many :projects When I try to paginate(:employees, :include => :projects) I get the error "Association named ''projects'' was not found; perhaps you misspelled it?" I can :include other models that the Person class has_many or habtm of, and if I just refer to a @employee.projects collection that works too. Does anyone see what the problem could be? Thanks, Brian Gates __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
B Gates wrote:> Here''s the setup (working off Rails 1.1.4): > > Class Project > belongs_to :employee > > Class Employee < Person > has_many :projects > > When I try to paginate(:employees, :include => > :projects) I get the error "Association named > ''projects'' was not found; perhaps you misspelled it?" > > I can :include other models that the Person class > has_many or habtm of, and if I just refer to a > @employee.projects collection that works too. > > Does anyone see what the problem could be?If this is the actual code, Project needs to extend ActiveRecord::Base (and I''m assuming Person already does so). Also remember you have to restart the web server when you change things in the database. - Walter
Yes, the models do extend ActiveRecord::Base. And the webserver was restarted. If I change the association to Person has_many :projects (and specify :foreign_key => ''employee_id'') the eager loading works fine. Is there a reason the sti causes a problem? I glanced at the changelog for 1.1.4, and thought I saw that this prblem had been identified and fixed. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com