Skip to content

Instantly share code, notes, and snippets.

@metasoarous
Created September 12, 2009 10:00
Show Gist options
  • Save metasoarous/185783 to your computer and use it in GitHub Desktop.
Save metasoarous/185783 to your computer and use it in GitHub Desktop.
def build_creation_settings(params)
type = self.attributes["creation_setting_type"]
#create an array with the name of all application models
models = []
Dir.glob( RAILS_ROOT + '/app/models/*' ).each do |f|
models << File.basename( f ).gsub( /^(.+).rb/, '\1').camelize
end
#check to make sure that the type is actually a model before passing it
#through the scarriness of eval()
if models.include? type
self.creation_setting = eval(type).new(params)
else
raise "We have a run_setting_type that is not any recognized model - perhaps we have hackers on the loose!!!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment