diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-27 13:03:07 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-27 21:29:59 +0200 |
commit | 8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1 (patch) | |
tree | a09d54d92582028e343d731fa9fafef352145119 /railties/lib/generators/active_record/model/model_generator.rb | |
parent | 9acb721e6a4e78bdd1b9d5f9fb80f4ed2b263b34 (diff) | |
download | rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.tar.gz rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.tar.bz2 rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.zip |
Initial scratch of model generators.
Diffstat (limited to 'railties/lib/generators/active_record/model/model_generator.rb')
-rw-r--r-- | railties/lib/generators/active_record/model/model_generator.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb new file mode 100644 index 0000000000..448bf5c37f --- /dev/null +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -0,0 +1,33 @@ +module ActiveRecord + module Generators + class ModelGenerator < Base + argument :attributes, :type => :hash, :default => {}, :banner => "field:type, field:type" + + check_class_collision + + # TODO Add parent support + + # TODO Add DEFAULTS support + class_option :skip_timestamps, :type => :boolean, :default => false, + :desc => "Don't add timestamps to the migration file" + + # TODO Make this a invoke_if + # TODO Add DEFAULTS support + class_option :skip_migration, :type => :boolean, :default => false, + :desc => "Don't generate a migration file" + + def create_model_file + template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") + end + + # TODO Add migration support + def create_migration_file +# unless options[:skip_migration] +# m.migration_template 'migration.rb', 'db/migrate', :assigns => { +# :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}" +# }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" +# end + end + end + end +end |