This seems rather ugly. I am thinking that this needs to be in the model
but I am looking to obtain the date for a tb test…
@tb = Innoculation.find(:all,
:conditions => [“personnel_id = 1 AND innoc_type = ‘TB’”],
:order => ‘innoc_date DESC’)
=> [#<Innoculation:0xb77ed234 @attributes={“id”=>“1”,
“innoc_type”=>“TB”, “personnel_id”=>“1”, “innoc_date”=>“2006-05-27”}>]
@last_tb = @tb[0][:innoc_date]
=> #<Date: 4907765/2,0,2299161>
which says to me that in the personnel model, it should be something
like this…
def last_tb personnel_id
@tb = Innoculation.find(:all,
:conditions => ["personnel_id = ? AND innoc_type = ‘TB’,
personnel_id "],
:order => ‘innoc_date DESC’)
@last_tb = @tb[0][:innoc_date]
end
Is there a simpler way?
Craig