Hi
I have an ActiveRecord class ServiceDesk and a string “ServiceDesk”
.How can I convert the string “ServiceDesk” to create a new object of
the class ServiceDesk?
Concept is made clear below.
model = “ServiceDesk” // Now the variable, model, contains the string
“ServiceDesk” which is the name of an active record class.
I am trying to achieve the following. how can I really achieve this…
Thanks in advance.
I have an ActiveRecord class ServiceDesk and a string “ServiceDesk”
.How can I convert the string “ServiceDesk” to create a new object of
the class ServiceDesk?
Since you’re working with Rails and therefore ActiveSupport, you can do:
“ServiceDesk”.constantize.new
~ j.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.