title: Method for getting polymorphic relationship table name in Rails. Meta-programming
body: <p>I want to test if a Polymorphic child belongs to parent.</p>
  
  <pre><code>@event.eventable_id == @current_user.id and @event.eventable_type == current_user.class.name
  </code></pre>
  
  <p>Now this is ugly and shouldn't be in the view like this.  But I'd like to do this check for every polymorphic object.  So I need a meta-programming way to figure out the naming scheme of the polymorphic relationship table.</p>
  
  <pre><code>phone to phonable
  social to sociable
  etc.
  </code></pre>
  
  <p>The method would look great like this.</p>
  
  <pre><code>if @event.belongs_to(current_user) #&lt;NoMethodError: undefined method `belongs_to' for #&lt;Event:
  </code></pre>
  
  <p>So I need a helper method to check the polymorphic relationship.  If I could get the name scheme of any polymorphic child like this</p>
  
  <pre><code>@event.polymorphic_relationship_table_name
  </code></pre>
  
  <p>I could then incorporate it in a meta-programming helper.  If there's already a solution built for this please let me know.</p>