Boring down the heirarchy in Rails
Wasn't aware that the following is possible:
This gets all the milestones of the first project that belongs to the first
account.
from Rails Digest, Vol 13, Issue 424 Message 8
class Account < ActiveRecord::Base
has_many :projects
end
class Project < ActiveRecord::Base
belongs_to :account
has_many :milestones
end
class Milestone < ActiveRecord::Base
belongs_to :project
end
Account.find(:first).projects.first.milestones
This gets all the milestones of the first project that belongs to the first
account.
from Rails Digest, Vol 13, Issue 424 Message 8

0 Comments:
Post a Comment
<< Home