I have two bits of data I'm working with here.
A "question": This is an [example] string for [testing] and [what not].
And then I have an array of objects (called "answers") from my database:
[#<Answer id: 137, question_id: 207, text: "example">, #<Answer id: 138, question_id: 207, text: "testing">, #<Answer id: 139, question_id: 207, text: "what not"]
What I need to do is replace the bracketed text in the question ([example]) with a link containing data from the corresponding object.
So [example] might become <a href="#" data-answer="137" data-question="207">example</a>.
How can I do that?
Answeris your custom class, you have tell how to access the id and the question id in anAnswerinstance. Otherwise, it's impossible to answer.