How to get the join table name in an ActiveRecord association?
<p>I am needing to find the name of a join table between two classes, for example, Client and Language. I need to be able to do this programmatically, because I am generating a complex SQL query that must automatically account for new relationships.</p>

<p>My best idea is to use table_name on both classes and combine them by the join table name convention:</p>

<pre><code>if Client.table_name &lt; Language.table_name
  Client.table_name + '_' + Language.table_name
else
  Language.table_name + '_' + Client.table_name
end
</code></pre>

<p>However, this does not account for a custom join table name. Is there a way to get the actual join table name?</p>