Created
September 12, 2009 10:00
-
-
Save metasoarous/185783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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