I'm using ruby on rails and I currently have code
if level == "Grad"
include Grad
else
include Undergrad
Where level is a string that say either "Grad" or "Undergrad"
I want to use meta programming to include the correct module without the if statement
something like this.
send :include, level
How do I do this. What is the best way to do this?
include "#{level}".constantize
. Does this work for you?