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
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’)
How can I find all the teachers with “on break” in attribute column name
stored in the variable hold_period ?