I am trying to DRY some code in some of my controllers and keep getting an undefined method error. Details as follows: Some controllers dynamically generate methods inside a loop using define_method. E.g.: [''shipment_product'', ''transport''].each do |object_name| sub_model_class = object_name.camelize.constantize define_method("list_#{object_name}") do @sub_model = sub_model_class.new render ''shared/list_sub_model'' end .... end I tried to move this code to application.rb as separate methods and call the methods from each controller. E.g.: in application.rb: def sub_model_list_for(object_name) sub_model_class = object_name.camelize.constantize define_method("list_#{object_name}") do @sub_model = sub_model_class.new render ''shared/list_sub_model'' end end in the controller: [''shipment_product'', ''transport''].each do |object_name| sub_model_list_for(object_name) .... end However if I do this, upon loading the controller I get undefined method error for sub_model_list_for. (same thing happens in the console if I ''load whatever_controller.rb''). Any ideas? This code is actually in two controllers but probably will generate some others that might use this code and I don''t want to repeat the beast all over the place. Thanks in advance, Atha --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---