How do I convert a string to a class method?

后端 未结 4 918
遇见更好的自我
遇见更好的自我 2020-12-13 04:19

This is how to convert a string to a class in Rails/Ruby:

p = \"Post\"
Kernel.const_get(p)
eval(p)
p.constantize

But what if I am retrievin

4条回答
提交回复
热议问题