basic belongs_to question.

Can't think it through... list belongs_to :projects

I can get a size of items in a list for a project

   project.lists.size

list can be marked "done" how do I get a size for list not marked done? so if I have three unfinished items in a list of eight i'd like to see

fix project 3 tasks

not

fix project 8 tasks

Can't think it through... list belongs_to :projects

I can get a size of items in a list for a project

   project.lists.size

list can be marked "done" how do I get a size for list not marked done?

In your Project model add:

has_many :unfinished_lists, :class_name => 'List', :conditions => 'completed_at is null'

Then use:

project.unfinished_lists.size

-philip

Philiip, thank you. let me see if i understand this...

has_many :lists makes the assumption that the class is list, i want everything and the name of this object is lists? i could say has_many :the_longest_name_possible, :class_name => 'List' i would get the same results except i need to reference the_longest_name_possible?

I'm going to try this and look back at my AWDR book because when i saw you response it looked familiar.

thanks again.

John