The cols array contains the name of the columns (which become
accessors on your ActiveRecord model) in their order for row 1. Here
you use it to provide the name of the column in mat_row, and send
simply invokes the getter.
How would this send invoke a getter? Where are we passing symbol of
getter? I tried direct copy pasting, got syntax error: wrong number of
arguments (1 for 0))
Oh ok. I am sorry my bad. mat_row.send cols[i%4], 80 . IN this 80 is
being taken as argument for send. I got this corrected.
Thanks a lot for solution.
So if no symbol is passed to send, it calls getter?
Actually, you *are* passing a method name (preferably a symbol). The
symbol happens to be stored in the cols array. From the inside out,
you are:
1. Looking up the i+n modulo 4th item in the cols array
2. Invoking send on the result of the look up (thus getting the value
from the nth column as desired).
3. Truncating to the desired length
4. html escaping
Actually, you *are* passing a method name (preferably a symbol). The
symbol happens to be stored in the cols array. From the inside out,
you are:
1. Looking up the i+n modulo 4th item in the cols array
2. Invoking send on the result of the look up (thus getting the value
from the nth column as desired).
3. Truncating to the desired length
4. html escaping
On Feb 19, 1:01 pm, Sandeep Gudibanda <rails-mailing-l...@andreas-