<commit_before>http://plugins.ardes.com > nested_has_many_through

= nested_has_many_through

A fantastic patch/plugin has been floating around for a while:

* http://dev.rubyonrails.org/ticket/6461
* http://code.torchbox.com/svn/rails/plugins/nested_has_many_through

obrie made the original ticket and <NAME> released the first version of
the plugin, under the MIT license.  Many others have contributed, see the trac
ticket for details.

Here is a refactored version (I didn't write the original), suitable for edge/2.0-stable
with a bunch of acceptance specs.  I'm concentrating on plugin usage, once 
it becomes stable, and well enough speced/understood, then it's time to pester
rails-core.

== Why republish this on github?

* The previous implementations are very poorly speced/tested, so it's pretty 
  hard to refactor and understand this complicated bit of sql-fu, especially
  when you're aiming at a moving target (edge)
* the lastest patches don't apply on edge
* github - let's collab to make this better and get a patch accepted, fork away!

== Help out

I'm releasing 'early and often' in the hope that people will use it and find bugs/problems.
Report them at http://ianwhite.lighthouseapp.com, or fork and pull request, yada yada.

== History

Here's the original description:

  This plugin makes it possible to define has_many :through relationships that
  go through other has_many :through relationships, possibly through an
  arbitrarily deep hierarchy. This allows associations across any number of
  tables to be constructed, without having to resort to find_by_sql (which isn't
  a suitable solution if you need to do eager loading through :include as well).

== Contributors

* <NAME>
* terceiro
* shoe
* mhoroschun
* <NAME>

Get in touch if you should be on this list

== Show me the money!

Here's some models from the specs:

  class Author < User
    has_many :posts
    has_many :categories, :through => :posts, :uniq => true
    has_many :similar_posts, :through => :categories, :source => :posts
    has_many :similar_authors, :through => :similar_posts, :source => :author, :uniq => true
    has_many :posts_of_similar_authors, :through => :similar_authors, :source => :posts, :uniq => true
    has_many :commenters, :through => :posts, :uniq => true
  end
  
  class Post < ActiveRecord::Base
    belongs_to :author
    belongs_to :category
    has_many :comments
    has_many :commenters, :through => :comments, :source => :user, :uniq => true
  end
  
The first two has_manys of Author are plain vanilla, the last four are what this plugin enables

  # has_many through a has_many :through
  has_many :similar_posts, :through => :categories, :source => :posts

  # doubly nested has_many :through 
  has_many :similar_authors, :through => :similar_posts, :source => :author, :uniq => true

  # whoah!
  has_many :posts_of_similar_authors, :through => :similar_authors, :source => :posts, :uniq => true

  # has_many through a has_many :through in another model
  has_many :commenters, :through => :posts, :uniq => true

== What does it run on?

Currently it's running on edge, 2.0-stable and 2.1-stable

If you want to run the CI suite, then check out garlic_example.rb (The CI suite
is being cooked with garlic - git://github.com/ianwhite/garlic)
<commit_msg>Added masterkain to contributors list<commit_after>http://plugins.ardes.com > nested_has_many_through

= nested_has_many_through

A fantastic patch/plugin has been floating around for a while:

* http://dev.rubyonrails.org/ticket/6461
* http://code.torchbox.com/svn/rails/plugins/nested_has_many_through

obrie made the original ticket and <NAME> released the first version of
the plugin, under the MIT license.  Many others have contributed, see the trac
ticket for details.

Here is a refactored version (I didn't write the original), suitable for edge/2.0-stable
with a bunch of acceptance specs.  I'm concentrating on plugin usage, once 
it becomes stable, and well enough speced/understood, then it's time to pester
rails-core.

== Why republish this on github?

* The previous implementations are very poorly speced/tested, so it's pretty 
  hard to refactor and understand this complicated bit of sql-fu, especially
  when you're aiming at a moving target (edge)
* the lastest patches don't apply on edge
* github - let's collab to make this better and get a patch accepted, fork away!

== Help out

I'm releasing 'early and often' in the hope that people will use it and find bugs/problems.
Report them at http://ianwhite.lighthouseapp.com, or fork and pull request, yada yada.

== History

Here's the original description:

  This plugin makes it possible to define has_many :through relationships that
  go through other has_many :through relationships, possibly through an
  arbitrarily deep hierarchy. This allows associations across any number of
  tables to be constructed, without having to resort to find_by_sql (which isn't
  a suitable solution if you need to do eager loading through :include as well).

== Contributors

* <NAME>
* terceiro
* shoe
* mhoroschun
* <NAME> (http://github.com/ianwhite)
* Claudio (http://github.com/masterkain)

Get in touch if you should be on this list

== Show me the money!

Here's some models from the specs:

  class Author < User
    has_many :posts
    has_many :categories, :through => :posts, :uniq => true
    has_many :similar_posts, :through => :categories, :source => :posts
    has_many :similar_authors, :through => :similar_posts, :source => :author, :uniq => true
    has_many :posts_of_similar_authors, :through => :similar_authors, :source => :posts, :uniq => true
    has_many :commenters, :through => :posts, :uniq => true
  end
  
  class Post < ActiveRecord::Base
    belongs_to :author
    belongs_to :category
    has_many :comments
    has_many :commenters, :through => :comments, :source => :user, :uniq => true
  end
  
The first two has_manys of Author are plain vanilla, the last four are what this plugin enables

  # has_many through a has_many :through
  has_many :similar_posts, :through => :categories, :source => :posts

  # doubly nested has_many :through 
  has_many :similar_authors, :through => :similar_posts, :source => :author, :uniq => true

  # whoah!
  has_many :posts_of_similar_authors, :through => :similar_authors, :source => :posts, :uniq => true

  # has_many through a has_many :through in another model
  has_many :commenters, :through => :posts, :uniq => true

== What does it run on?

Currently it's running on edge, 2.0-stable and 2.1-stable

If you want to run the CI suite, then check out garlic_example.rb (The CI suite
is being cooked with garlic - git://github.com/ianwhite/garlic)

{'fraction_non_alphanumeric': 0.08592349073520622, 'fraction_numerical': 0.002988643156007173, 'mean_word_length': 4.2992874109263655, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4569974', 'n_tokens_mistral': 2054, 'n_tokens_neox': 1935, 'n_words': 821}