Say I have a model class called Game. I also have a string call ‘game’.
How can I do some parsing magic on the string to have a reference to
the model Game. So I can perform class methods. (Game.find(1))
thanks
Say I have a model class called Game. I also have a string call ‘game’.
How can I do some parsing magic on the string to have a reference to
the model Game. So I can perform class methods. (Game.find(1))
thanks
On Dec 22, 2006, at 12:45 PM, warhero wrote:
Say I have a model class called Game. I also have a string call
‘game’.
How can I do some parsing magic on the string to have a reference to
the model Game. So I can perform class methods. (Game.find(1))thanks
‘game’.camelize.constantize.find 1
– Ezra Z.
– Lead Rails Evangelist
– [email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)
Vary dangerous, you need to be sure what is inside this string.
it’s like the notorious Eval.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs