From: arjun ghosh Date: 2007-05-07T23:14:04+09:00 Subject: Re: [Rails] passing by value of object of a model ------=_Part_13639_8916122.1178547243029 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hi, i realized that from Alex's msg. Though Pat's info helped me to learn this way of discovering the class from a name. i finally have used the object reference method as it seemed more intutive and simpler as i already had the object for the above said model. Any way thanks to all for the quick help. This is also one thing i like about RoR - awsome community support..:-) ciao. A quick question - This is for Pat and Nanyang -- Pat u told about "food_dept".classify.constantize and Nanyang u told the method "food_dept".camelize.constantize and when i ran it in console and checked for class, both gave me class type. so whats the diffrence? -AG On 5/7/07, David Chelimsky wrote: > > On 5/7/07, arjun ghosh 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 > > -~----------~----~----~----~------~----~------~--~--- > > > > > > ------=_Part_13639_8916122.1178547243029--