On 15 November 2011 18:27, PandaR1 <[email protected]> wrote: > Hi > This is difficult (for me, at least ;) ) > I have a model named Measureunit and another named Vendor > Each vendor has a measureunit for the currency it use, and the association > is currency > In vendor.rb I have > belongs_to :currency, :class_name => "Measureunit" , :foreign_key => > "currency_id" > > How can I recover the class name from the association name (eg. I have the > string 'Currency' and I look for > a method that return 'Measureunit')
I don't understand what you mean by 'I have the string "Currency"' but if you have a vendor object then you can say vendor.currency.class.name Also I do not understand why you would want to do this so I have probably misunderstood the question. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

