Skip to content

Instantly share code, notes, and snippets.

@newportandy
Created January 15, 2010 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newportandy/277683 to your computer and use it in GitHub Desktop.
Save newportandy/277683 to your computer and use it in GitHub Desktop.
#!/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