I want to create a variable dynamic. I have defined some classes and
depending on data I get from a database I need to construct an object
eg:
now I do
if type=="car"
variab = Car.new
elsif type="boat"
variab = Boat.new
end
can I do something like
variab = Instance.new(type)
Following this: can I give dynamic variablenames?
now I do
if type=="car"
car_string = Car.new
elsif type="boat"
boat_string = Boat.new
end
can I do something like
dynamicpart_string = Instance.new(type)
Fred Cheung has answered this post for you on the Rails mailing list.
David
--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
INTRO TO RAILS June 24-27 London (Skills Matter)
See http://www.rubypal.com for details and updates!