The model Teacher has attributes
of :name, :period1, :period2, :period3In a part of the view I am iterating with an "upto" clause and have made an instance variable named "hold_period" that has a strings like "period1" , "period2"
I am successfully using things like teacher.send(hold_period) to
access period column data from a given teacher instance.What I want to do now is search a whole collection of teachers and
find matches to a string like "on break" in the attribute column stored in hold_period.If I knew it was period1 I would go
@on_break = @teachers.find_by_period1("on_break")
but I don't think I can go
@on_break = @teachers.find_by_(hold_period)("on_break')
Why the dynamic finder obsession?
@on_break = @teachers.find :all, :conditions => {hold_period =>
"on_break"}
should do the trick (you might have to convert hold_period to a
symbol, can't remember off the top of my head.
Fred