Created
February 23, 2014 11:40
-
-
Save StanBoyet/9170268 to your computer and use it in GitHub Desktop.
Generate form, helper etc for model
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
require 'rubygems' | |
require 'active_support/core_ext' | |
schema = File.read('db/schema.rb') | |
schema.scan(/create_table "(\w+)",.*?\n(.*?)\n end/m).each do |name, ddl| | |
puts "rails generate scaffold #{name.classify} " + | |
ddl.scan(/t\.(\w+)\s+"(\w+)"/). | |
reject {|type,name| %w(created_at updated_at).include? name}. | |
map {|type,name| "#{name}:#{type}"}.join(' ') | |
end | |
#If you run this, you will get a series of commands. | |
#In a new directory, create a new rails application, and then run these commands (simply copying and pasting them will do). | |
#Grab the files you want. Delete the directory when you are done. | |
#from http://stackoverflow.com/a/6645304 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment