Skip to content

Instantly share code, notes, and snippets.

@fizx
Created October 6, 2008 16:06
Show Gist options
  • Save fizx/15069 to your computer and use it in GitHub Desktop.
Save fizx/15069 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# This script generates RESTful scaffolds from your pre-existing models.
# Copyright 2008 Kyle Maxwell, available under the MIT licence.
#
require "rubygems"
require "active_support"
content = File.read(File.dirname(__FILE__) + "/db/schema.rb").split("create_table")
content.shift
content.each do |section|
model = section[/"([^"]+)"/, 1].singularize
arr = section.scan(/t\.(\w+)\s+"([^"]+)"/)
values = arr.map{|type, name| "#{name}:#{type}"}.join(" ")
puts %[./script/generate scaffold #{model} #{values}]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment