Is there a way with ActiveRecord to get ahold of a collection containing each association? I want to write a rake task that will dump a model and all its related models to yaml. Thanks, Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: wrath.rubyonrails.org/pipermail/rails/attachments/20060323/abdf4305/attachment.html
I''m sorry David, I can''t answer but I would like to know as well.. On 3/24/06, David Clements <clements@colorado.edu> wrote:> > Is there a way with ActiveRecord to get ahold of a collection containing > each association? I want to write a rake task that will dump a model and > all its related models to yaml. > > Thanks, > Dave > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: wrath.rubyonrails.org/pipermail/rails/attachments/20060323/7a6f467c/attachment.html
Daniel ----- wrote:> I''m sorry David, > > I can''t answer but I would like to know as well..[Model.instance_methods - ActiveRecord::Base.instance_methods].flatten.delete_if{|x|x=~/create_|remove_|destroy|build_|add_|set_|validate_|_count|=|[?]/}.map{|x|m=Model.find_first.send(x.to_sym);m if m.class.superclass == ActiveRecord::Base||if m.respond_to?(:first);m.first.class.superclass == ActiveRecord::Base;end}.compact.flatten Nasty. I don''t know if there is a real way to do it. joey__ -- Posted via ruby-forum.com.