has_many :through fixes and thoughts

I've made a couple of fixes ( some are really straight forward ) for HMT relations - would be great if someone can check and commit/comment.

http://dev.rubyonrails.org/ticket/8785 http://dev.rubyonrails.org/ticket/8786 http://dev.rubyonrails.org/ticket/8787 http://dev.rubyonrails.org/ticket/8800 http://dev.rubyonrails.org/ticket/8801 http://dev.rubyonrails.org/ticket/8802

I'm more interested in knowing the thoughts that went behind adding create! for HMT. Logically/intuitively speaking, if create! is supported then build, create, << should be supported too.

But create! works only when the source association is minimal and has no validation ( just like habtm join table, only with id) - and polymorphic ( it tries to find source_id in source table otherwise! ) . I think it needs a bit of rethinking and cases/conditions where it actually work, should be properly defined/documented, as the current behavior is totally unexpected.

I personally feel any method that bypasses source reflection logic, should raise exception as default behavior. But at the same time, user should probably be given an option to override the behavior, may be something like :

has_many :comments, :through => :posts, :writer => [:create, :new]

But then user should know what he's doing if he uses it. Or even better, just let users define their own methods and allow nothing by default.

Thoughts ?

Thanks, Pratik