I have two entities (Department and Project) that extends
ActiveRecord::Base. The department is mapped to have many projects. When
i make a query using the find(:all) (Department.find(:all)), i get a
collection of the departments with the attributes(id, project_id) of the
database. I would like to receive in each department one entity of the
project class.
-----------------------------------------------------------------------
class Department < ActiveRecord::Base
has_many :projects # <--- note.. your forgot to use the plural form here
end
class Project < ActiveRecord::Base
belongs_to :department # <--- Did you forget to do this
-----------------------------------------------------------------------
class Department < ActiveRecord::Base
has_many :projects # <--- note.. your forgot to use the plural form here
end
class Project < ActiveRecord::Base
belongs_to :department # <--- Did you forget to do this