I believe what you're saying is that you have the Vendor class, and
the name of the association as a string, 'Currency'. You want to look
at The ActiveRecord::Reflection documentation, specifically
reflect_on_association (
http://apidock.com/rails/ActiveRecord/
Reflection/ClassMethods/reflect_on_association). That gives you back
an AssociationReflection, which has a bunch of information for you:
http://apidock.com/rails/ActiveRecord/Reflection/AssociationReflection.
Specifically again, you likely want klass on that, which should return
the class of the association; do be aware that its a little bit more
complex for polymorphic relationships if that's necessary to support.
So in summary what you likely want is something like
s = "Currency"
association_name = s.underscore # Or
whatever transformation takes your string to your association name
reflection = Vendor.reflect_on_association(association_name) #
Returns the AssociationReflection object
reflection.klass #
Returns the class object, in this case Measureunit
HTH,
\Peter