$ssf
def find_class(class_name, stack = )
FileClass.find(:all, :conditions => ["class_name = ?",
class_name]).each do |file_class|
FileInclude.find(:all, :conditions => ["file_name = ?",
file_class.file_name]).each do |file_include|
FileClass.find(:all, :conditions => ["file_name = ?",
file_include.file_name]).each do |xxxx|
next if stack.include?(xxxx.class_name)
begin
find_class(file_class.class_name, stack)
p file_class
p "============================"
p file_include
p "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------"
p xxxx
rescue SystemStackError => ssf
p $ssf = ssf
end
end
end
end
end
rake aborted!
SystemStackError: stack level too deep: SELECT * FROM `file_includes`
WHERE (file_name = 'IMAgentHome')
You have not mentioned how should recursion stop properly. Anyway, code also doesnt look very clean and I think not very efficient too. My suggestion is first fetch all FileClass using conditions in an array, include all the FileInclude as well (using :include) Then select, reject the record you want to.
Sorry, if I haven’t understood your problem correctly.