I have an array arr = ["model", "engine", "year", ................] where each element is an attribute name of Car model.
I am trying to push these specific attribute values to another array
Car.all.each do |mycar|
another_array << arr.map{ |attr| mycar.attr }
end
This of course gives the expected no method error .attr for <object>. What is the correct way to do this ??
EDIT
I know about .send() method but I found that some fields encrypted using attr-encrypted gem are not decrypted properly when I use .send(). So I have to try something else like this