Created
January 15, 2010 01:09
-
-
Save newportandy/277683 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
#!/usr/bin/env /home/andy/dev/ruby/dog_application/script/runner | |
#In this case the script is written to be executed in the "dog_application" rails root folder. | |
#The table to scaffold, Really should take a command line variable... | |
input = "dog" | |
eval "class #{input.humanize} < ActiveRecord::Base | |
end" | |
columns = {} | |
eval"#{classname}.columns_hash.map do |k,v| | |
columns[k] = v.type unless [\"id\",\"created_at\",\"updated_at\"].include? k.downcase | |
end" | |
if !columns.empty? then | |
columns_string = columns.keys.inject("") do |results, key| | |
results = results + " " + [key, columns[key]].join(":") | |
end | |
puts "Running command: script/generate scaffold #{input} #{columns_string}--skip-migration" | |
puts `script/generate scaffold #{input} #{columns_string} --skip-migration` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment