gsw
2013-Jun-28 13:57 UTC
Modelist gem now helps find path between ActiveRecord models and search by name/table/assoc/column
We have a complex legacy schema with a lot of tables and models, and I can''t keep all of the paths between tables in my head, so just wrote something that could help find the path between any two models just by entering their model names like: bundle exec modelist paths my_model_1 my_model_2 which results in (greatly simplified because a full actual response is much, much longer): checking for path from foobar to barfoo... +++++++-+-++--+------ Paths from foobar to barfoo (2): foobar.foo -> foo.barfoos -> barfoo foobar.barfoo -> barfoo (shortest path last) and: bundle exec modelist search partial_search_string results in: Models: Foo (table: foos) Foobar (table: foobars) Associations: Bar (table: bars), association: foo (macro: belongs_to, options: {}) Loo (table: loos), association: f_users (macro: has_one, options: {:foreign_key=>:foo_id}) Check it out and please report issues in github and do PR''s for fixes: https://github.com/garysweaver/modelist/ It is a little messy at the moment, but it seems to be working ok for me, unless I''m missing something. Gary -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/28f69b2d-9b7b-4f07-a3ef-3839517a3e68%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.