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:
    @answer = User.first.answer
    User.last.send("#{@answer}")
You need to know which attribute you are querying for in order to use the dynamic finders, e.g.
User.find_by_answer(@answer).last
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论