From: dis guy Date: 2012-10-11T09:27:22+09:00 Subject: ghost methods and dynamic methods I am a newbie to ruby please explain your answers thoroughly. I am having a lot of difficulties with the syntax. Thanks for the help. I want to call this missing method: redcars= myclass.select_cars_where_color("==", "red") My missing method should look like this, but I cannot get it work: def self.method_missing(method, *args) myclass.cars #populate a list of cars prop = method.to_s.split("where").last puts prop.sub!(/^_/, '') #print out the query part for the method. #for example this could be "color" puts args.join(',') #for example this could be ==, red #this is the part I cannot get it right: #I want to have: #@cars.select { |el| el.color == red} #I tried this unsuccessfully: #@cars.select { |el| el."@#method.to_s.split("where").last.sub! #(/^_/, '')" args.first args.last } #how do I construct this line in my missing method from the above code? end -- Posted via http://www.ruby-forum.com/.