Abhinav Saxena wrote:
> 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.
> 
> --
> Thanks,
> Abhinav
> http://twitter.com/abhinav
> 
> 
> 
> On Thu, Sep 3, 2009 at 2:45 PM, Ahmet Kilic <

sorry, my code is not good one, but the code is here,

  def find_class(class_name, stack = [])
   puts(("\t" * stack.size) + class_name)
#   puts(("\t" * stack.size) + "#{class_name}")
   stack.push class_name
    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 |file_class|
          next if stack.include?(file_class.class_name)
         find_class(file_class.class_name, stack)
        end
      end
    end
   stack.pop
  end

I am testing which part is getting error..

> first fetch all FileClass using conditions in an array, include all the
> FileInclude as well (using :include) Then select, reject the record you 
> want

could you provide a simple example for this(using :include), please!


-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to