rails/rails — pull request #8630 by route (2012-12-27 11:59:01+00:00)
Title: Check joined table name by table_name

In my app I use STI and overridden table_name but `habtm` in it doesn't work properly, and I have to set options on it forcibly. I'll show you example:
```ruby
module Namespace
class Base < ActiveRecord::Base
self.table_name = 'tablename'
has_and_belongs_to_many :somethings
end
end

class Namespace::Child < Namespace::Base
end
```
It gives me advantage I can keep all these stuff inside `namespace` directory and it will be auto loaded by AS and it's still STI. But HABTM relies on classes when it calculates table names, so for join table it chooses `bases_somethings` instead of `tablename_somethings`. Of course I can set these options manually and it will work. I left comment in this PR and it has small refactoring proposed by @jonleighton in comment and actually this refactoring is the way to go if we want to use table_name.