Skip to content

Instantly share code, notes, and snippets.

@elhoyos
Created July 5, 2012 21:43
Show Gist options
  • Save elhoyos/3056674 to your computer and use it in GitHub Desktop.
Save elhoyos/3056674 to your computer and use it in GitHub Desktop.
Dynamically load a Model
class_name = "publication".classify
the_class = Object.const_get(class_name)
# or
the_class = class_name.constantize
# get Publication
the_class.find(1)
# equal to
Publication.find(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment