Could someone please tell me how I can use find_by_attribute with a variable which defines what kind of attribute I am looking for?
For instance,
@answer = User.first.answer
User.last.find_by_attribute(@answer)
The answer attribute has the type string
I hope someone can show me how this could work
EDIT
I just realised that this doesn’t doesn’t get me the results I’m looking for… Here’s actually what I need: the name of the attribute I’m trying to access from another user is stored in the answer attribute. So I would need something like User.@answer … but this doesn’t work of course
EDIT2
Okay here the solution to my problem:
@answer = User.first.answer
User.last.send("#{@answer}")
=> true
Okay here the solution to my problem: