Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.