find with dynamic attribute name

The model Teacher has attributes
of :name, :period1, :period2, :period3

In 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

Why the dynamic finder obsession?

I dunno.. seems pretty silly in hindsight.

for the record, if you absolute had to do it that way, you can always do
Foo.send("find_by_#{attribute_name}", attribute_value)

That said, I don't think there's much point. Dynamic finders increase
readibility compared to find :all, :conditions => '...', but once you
start mucking around with send and constructing the method name on the
fly you've lost that readability advantage.

Fred