Created
October 6, 2008 16:06
-
-
Save fizx/15069 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 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