Skip to content

Instantly share code, notes, and snippets.

@rafer
Created January 26, 2010 18:34
Show Gist options
  • Save rafer/287080 to your computer and use it in GitHub Desktop.
Save rafer/287080 to your computer and use it in GitHub Desktop.
def model_exists?(model_name)
begin
potential_model = model_name.constantize
rescue NameError
return false
end
ActiveRecord::Base.send(:subclasses).include?(potential_model)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment