diff options
Diffstat (limited to 'railties/lib/generators/active_record/model')
-rw-r--r-- | railties/lib/generators/active_record/model/model_generator.rb | 14 | ||||
-rw-r--r-- | railties/lib/generators/active_record/model/templates/model.rb | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/railties/lib/generators/active_record/model/model_generator.rb b/railties/lib/generators/active_record/model/model_generator.rb index 448bf5c37f..45e773fde1 100644 --- a/railties/lib/generators/active_record/model/model_generator.rb +++ b/railties/lib/generators/active_record/model/model_generator.rb @@ -5,16 +5,11 @@ module ActiveRecord check_class_collision - # TODO Add parent support + conditional_class_option :timestamps + conditional_class_option :migration - # 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" + class_option :parent, :type => :string, :default => "ActiveRecord::Base", + :desc => "The parent class for the generated model" def create_model_file template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") @@ -28,6 +23,7 @@ module ActiveRecord # }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" # end end + end end end diff --git a/railties/lib/generators/active_record/model/templates/model.rb b/railties/lib/generators/active_record/model/templates/model.rb index 0656b06dfe..fb337d10e6 100644 --- a/railties/lib/generators/active_record/model/templates/model.rb +++ b/railties/lib/generators/active_record/model/templates/model.rb @@ -1,4 +1,4 @@ -class <%= class_name %> < ActiveRecord::Base +class <%= class_name %> < <%= options[:parent] %> <% attributes.select {|attr| attr.reference? }.each do |attribute| -%> belongs_to :<%= attribute.name %> <% end -%> |