If I have @commentable, which could either be a Post or Article, can I extract the model name from the instance variable?
- You may always use is_a? to test for a certain type.Edvaldo Silva de Almeida Jr– Edvaldo Silva de Almeida Jr2016-03-09 09:52:58 +00:00Commented Mar 9, 2016 at 9:52
- The question always is: why do you need it? If you are planning to use it for forking your flow it will be a serious architectural error (breaking Demeter law) which you will need to pay for later.BroiSatse– BroiSatse2016-03-09 09:58:13 +00:00Commented Mar 9, 2016 at 9:58
- 1Possible duplicate of How do I get the name of a Ruby class?Brad Werth– Brad Werth2016-03-09 10:22:44 +00:00Commented Mar 9, 2016 at 10:22
Add a comment |