Must create a docs
folder and put models.yml
inside this folder.
Last active
May 9, 2016 19:21
-
-
Save egoens/14685c50c55a2e76b01b1fd00c464dc3 to your computer and use it in GitHub Desktop.
Generate/Destory rails scaffolding
This file contains hidden or 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
namespace :models do | |
desc "Scaffolds models & controllers based on models.yml file 'docs' folder" | |
task :create => :environment do | |
require 'yaml' | |
data = YAML.load_file Rails.root.join('docs', 'models.yml') | |
data.each do |key, values| | |
puts "Scaffolding #{key} #{values}" | |
`rails generate scaffold #{key} #{values}` | |
end | |
end | |
desc "Destroys scaffolds based on models.yml file 'docs' folder" | |
task :destroy => :environment do | |
require 'yaml' | |
data = YAML.load_file Rails.root.join('docs', 'models.yml') | |
data.each do |key, values| | |
puts "Destroying scaffold #{key}" | |
`rails destroy scaffold #{key}` | |
end | |
end | |
end |
This file contains hidden or 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
Customer | |
name:string | |
email:string | |
Product | |
title:string | |
cost:integer | |
SomeOtherModelName | |
attribute:column_type | |
attribute:column_type | |
attribute:column_type | |
attribute:column_type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment