I can’t see what’s wrong here but that’s probably just because I’m so
new to Rails! To get right into it… I have 4 tables that look like
this:
Sites
- id
Projects
- id
- site_id
- user_id
Tasks
- id
- project_id
- user_id
Users
- id
The corresponding models:
class Site < ARB
has_many :projects, :dependent => :delete_all
end
class Project < ARB
belongs_to :site
belongs_to :user
has_many :tasks, :dependent => :delete_all
end
class Task < ARB
belongs_to :project
has_one :user
end
class User < ARB
has_many :tasks
end
The idea is:
- If you kill a site you kill all of its projects (this works)
- If you kill a project you kill all of its tasks (this works if you
JUST delete a project but not if you delete an entire site)
I created a single site, then 4 projects and 5 tasks. I then deleted
the site. All of the projects were destroyed, but none of the tasks
were!? What am I doing wrong here?
My controller call to delete a site is pretty rudimentary:
Site.find(params[:id]).destroy
Ideas? Thanks for the help!
Greg