def belongs_to(*attrs)
      define_rid_method = attrs[1].try(:delete, :rid)
      super.tap do
        if define_rid_method != false
          relationship_name = attrs[0]
          rel = reflections[relationship_name] || reflections[relationship_name.to_s]

          return if rel.options[:polymorphic] # If we don't know the class, we cannot find the record by rid.

          class_name = rel.options[:class_name] || relationship_name.to_s.classify
          related_class = class_name.constantize
          define_rid_accessors(related_class, relationship_name) if related_class.attribute_names.include? "rid"
        end
      end
    end
def belongs_to(*attrs)
      define_rid_method = attrs[1].try(:delete, :rid)
      super.tap do
        if define_rid_method != false
          relationship_name = attrs[0]
          rel = reflections[relationship_name] || reflections[relationship_name.to_s]

          return if rel.options[:polymorphic] # If we don't know the class, we cannot find the record by rid.

          class_name = rel.options[:class_name] || relationship_name.to_s.classify
          related_class = class_name.constantize
          define_rid_accessors(related_class, relationship_name) if related_class.attribute_names.include? "rid"
        end
      end
    end
Augment the ActiveRecord belongs_to to also define rid accessors. For example: if you blog post belongs_to an
 author, on top of the methods #author, #author=, #author_id and #author_id=, it'll also have #author_rid and
 #author_rid= that allow you to retrieve the RID of the author or set another author by using the RID.

 @param attrs [Array] same as the parameters for ActiveRecord::Associations::ClassMethods.belongs_to except that
   passing rid: false will prevent the rid accessors from beign defined.
 @see ActiveRecord::Associations::ClassMethods.belongs_to