if sub.include?("html") path = File.join("/ACMServer_exe/ChatHistory",f,sub_folder_name,sub) @file_path << path @found_folder << sub_folder_name @chat_date << f end The above code has to be used in my controller repeatively in the same function. like below if something if sub.include?("html") path = File.join("/ACMServer_exe/ChatHistory",f,sub_folder_name,sub) @file_path << path @found_folder << sub_folder_name @chat_date << f end elsif if sub.include?("html") path = File.join("/ACMServer_exe/ChatHistory",f,sub_folder_name,sub) @file_path << path @found_folder << sub_folder_name @chat_date << f end else if sub.include?("html") path = File.join("/ACMServer_exe/ChatHistory",f,sub_folder_name,sub) @file_path << path @found_folder << sub_folder_name @chat_date << f end end Because Parameter will be changing. i want to reduce my legth of code. pls help how to make those code into function. and how can i call that function in to my controller. i dont have any idea how that function can return the output to my controoler function . Kinldy help me to learn . Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---