Re: [Rails] from string to field name

2010-05-14 Thread Michael Pavling
On 14 May 2010 19:24, Viorel wrote: > My problem is that ModelName has no field named field_name, it have > fields like field01, field02,...,field09. So, how do I transform a > string in a field name? > > puts ModelName.send(field_name) -- You received this message because you are subscribed t

Re: [Rails] from string to field name

2010-05-14 Thread Joshua Martin
What exactly are you trying to do with this? On Fri, May 14, 2010 at 2:24 PM, Viorel wrote: > I have something like this: > for xx in '01'..'09' > field_name='field'+xx > puts ModelName.field_name > end > > My problem is that ModelName has no field named field_name, it have > fields like fiel

[Rails] from string to field name

2010-05-14 Thread Viorel
I have something like this: for xx in '01'..'09' field_name='field'+xx puts ModelName.field_name end My problem is that ModelName has no field named field_name, it have fields like field01, field02,...,field09. So, how do I transform a string in a field name? It might be a trivial solution, b