Model reflections

I’d like to suggest to improve duck typing to obtain the model class:

I found these variations so far:

  • ActiveRecord::Base#class
  • ActiveRecord:Relation#model
  • ActiveRecord:Reflection#klass
  • ActiveModel:Name @klass

I’d like to suggest a duck method to obtain the model from any object (where that makes sense)

  • we should not reuse #model (that would collide with legacy code)
  • I’d suggest: #model_class (or #model_klass)

There are several methods from ActiveModel::Naming that may have what you need.

The docs have several examples on how to use it. Let me know if this works for you!