title: Programatically get the class of the belongs_to association in Rails 4
body: <p>Let's say I have some classes linked by a one-to-many relationship:</p>
  
  <pre><code>class A
    field :name, type: String
    has_many :b
  
  class B
    field :title, type: String 
    belongs_to :a
  </code></pre>
  
  <p>Let's also say I have an instance of B and I want to retrieve the class name(s) of his belongs_to relationship (in my example 'A', not the instance of type A linked to my B object).</p>
  
  <pre><code>a = A.new name: 'my A object'
  b = B.new title: 'my B object', a: a
  
  assert_equal b.get_relationships(:belongs_to), ['A'] #substitute "get_relationships" with something that actually exists :)
  </code></pre>
  
  <p>What should I do?</p>
  
  <p>I had a look at this <a href="https://stackoverflow.com/questions/8371574/is-there-a-way-to-list-all-belongs-to-associations">answer</a> on a similar topic (using reflection) but I couldn't manage to make it work. Maybe something has changed in Rails 4?</p>