Skip to content

Instantly share code, notes, and snippets.

@egoens
Last active May 9, 2016 19:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoens/14685c50c55a2e76b01b1fd00c464dc3 to your computer and use it in GitHub Desktop.
Save egoens/14685c50c55a2e76b01b1fd00c464dc3 to your computer and use it in GitHub Desktop.
Generate/Destory rails scaffolding

Requirements

Must create a docs folder and put models.yml inside this folder.

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
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