On 5/7/07, arjun ghosh <arjun4ruby / gmail.com> wrote:
> Hi,
> can anyone tell me - is it possible to pass a string name equivalent of a
> model name(example:- have a model called food_dept and i am passing the
> string "food_dept" to a method) and then covert(or cast) it to its original
> model equivalent so that i can use its object in the called method. and why
> i am i trying to this manner is because i want to avoid passing an object
> which will make it very heavy.

Unless I'm missing something (which is usually the case :) ), there
seems to be a misunderstanding of how variables work in Ruby.

When you pass food_dept (or FoodDept) to another method, you are not
passing the object itself, but rather a variable which holds a
reference to the object. What you suggest, passing its name and then
discovering the class from its name is far more expensive than simply
using the variable.

Cheers,
David

>i think there should be some better elegant
> manner of doing this. can any one help me with this?
> ciao
> -AG
>
>  --~--~---------~--~----~------------~-------~--~----~
>  You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
>  To post to this group, send email to
> rubyonrails-talk / googlegroups.com
>  To unsubscribe from this group, send email to
> rubyonrails-talk-unsubscribe / googlegroups.com
>  For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en
>  -~----------~----~----~----~------~----~------~--~---
>
>