How do I get the name of a Ruby class? -


मैं एक ActiveRecord ऑब्जेक्ट से क्लास का नाम कैसे प्राप्त करूं?

मेरे पास:

  परिणाम = उपयोगकर्ता.फंड (1)  

मैंने कोशिश की:

  result.class # = & gt; उपयोगकर्ता (id: पूर्णांक, नाम: स्ट्रिंग ...) result.to_s # = & gt; # & Lt; उपयोगकर्ता: 0x3d07cdc & gt; " 

मुझे इस स्ट्रिंग में ( उपयोगकर्ता ) क्लास नेम की आवश्यकता है। क्या इसके लिए कोई तरीका है?

मुझे पता है यह बहुत बुनियादी है, लेकिन मैंने दोनों रेल और रुबी के दस्तावेज़ों की खोज की है, और मुझे यह नहीं मिल सका।

आप ऑब्जेक्ट की क्लास पर कॉल करना चाहते हैं:

  result.class.name  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -