Hi all ,

I'm working in Rails but I'm sure this is a 100% Ruby question. I'm
trying to use define_method for the first time, it takes the name of the
method and a block.

I want to make multiple_methods each one with its name like
'sort_by_method1" , "sort_by_method2", ... , "sort_by_methodN"

The names are all right but within the block I get for all the methods I
created my last element (element N) in my $ingredients_column variable .

for column_name in $ingredients_columns do

   define_method("sort_by_" + column_name.human_name) {  @ingredients =
Ingredient.find(:all, :order => "#{column_name.human_name  } DESC")}

end

I think it's a bad use of the block, can anyone please help??

Kind Regards

Federico
-- 
Posted via http://www.ruby-forum.com/.