Q:

Possible to access nested table attributes in model?

My database schema includes a model(Tasks) that has_one of 14 different types of hazards. For example here is a pseudo relational structure. 
Task -> has_one Biohazard
     -> has_one Fallhazard

In the Task model I currently am trying to implement validation to determine when the forms for each of the hazards has been completed. The condition for this I want to use in my tasks model is as follows. 
    if self.Biohazard.total < 1000
       self.date_completed = Date.today
    end

I am currently getting the error "Undefined method" for this Biohazard.total. Is there a way to make that attribute accessible inside of the Task model? 

A:

As long as in the Biohazard model you have:
attr_accessible :total

All you should need in the Task model is:
self.biohazard.total

to get the total.

