Sha256: 8b43d878d0c79f9d152b0231b590aad8f4983392aba170bafbcd2f4d0fd8f319
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require 'rails/generators/active_record' require 'rails/generators/active_record/model/model_generator' module ActiveRecord class ScaffoldhubGenerator < ActiveRecord::Generators::ModelGenerator include Scaffoldhub::Helper source_root File.join(base_root, 'active_record', 'model', 'templates') class_option :scaffold, :default => 'default', :banner => "SCAFFOLD_NAME", :type => :string, :desc => "Scaffold to use" class_option :local, :default => false, :banner => "LOCAL SCAFFOLD", :type => :boolean, :desc => "Use a local scaffold, not scaffoldhub.org" class_option :migration, :type => :boolean class_option :timestamps, :type => :boolean class_option :parent, :type => :string, :desc => "The parent class for the generated model" def create_model_file find_template_file(:model) do |model_template| template model_template.src, File.join('app/models', class_path, "#{file_name}.rb") end end def create_migration_file return unless options[:migration] && options[:parent].nil? find_template_file(:migration) do |migration_template| migration_template migration_template.src, "db/migrate/create_#{table_name}.rb" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scaffoldhub-0.1.3 | lib/generators/active_record/scaffoldhub_generator.rb |
scaffoldhub-0.1.2 | lib/generators/active_record/scaffoldhub_generator.rb |