Ruby on Rails Monday, July 2, 2012

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJP8fnKAAoJEGRO9nGLm9Y8etgIAMQ13taReMoDSyxpbnu4su54
t6c2axb1lmSjo09E7SK5YbL5WCKqdBkEgDsD+7t99BJsZtrOM2PBGy5u9C6WQHEv
4jjhG25TgdVZENi39OMPDpmRkHPMQcBO2UZzNVw6kCCPJWnZMd4YxgyKbWhuSuyw
PmSI1/DRw6YUduk9UugQEKXY+SujfO36Ej93V7McJy0FlMyS2Dkk6/DMyEJK4gP+
a/VHgRflfJUWbaOlcZTmIiwHWzsylsVLRcmG5e1jH5CQ+jJ74EQbVKztws18o90E
5M77CvhHVnL4ASpOk56DemxUYscvIi9i6aY5Hy8i0fdy4J5W97eAlgTc/vXApLk=
=SJU2
-----END PGP SIGNATURE-----
On Mon, 02 Jul 2012 21:21:25 +0200
"Sebastian H." <lists@ruby-forum.com> wrote:

> hello guys
>
> i have a big problem and i don't know how to solve it -.-
>
> i have a data base. the models name is Blafoo
>
> if i go to console i create a new entry with tst = Blafoo.new(:d1 =>
> true)
>
> with Blafoo.d1 i can now see the calue of d1
>
> lets take a variable var = "d1"
>
> how can i get it working, that i can interpret var as d1
>
> so tst.(var) ?? gives me the value of tst.d1?
>
> thanks for help..
>
> im awaiting it so much!
>
> basti
>

Basically `test.d1` in this case is just a message. So you can call it
like: `test.send :d1`, or in your situation: `test.send var.to_sym`


--
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zapparov@jabber.ru

*Origin: Happy Hacking!

No comments:

Post a Comment