From 87d71b02b85a44ce461e533666ef5f0e43a46531 Mon Sep 17 00:00:00 2001 From: aditya-kapoor Date: Tue, 14 May 2013 00:27:52 +0530 Subject: Added documentation for model migration generation --- .../lib/rails/generators/active_record/model/model_generator.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb index 40e134e626..821df0e0d6 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -12,6 +12,9 @@ module ActiveRecord class_option :parent, :type => :string, :desc => "The parent class for the generated model" class_option :indexes, :type => :boolean, :default => true, :desc => "Add indexes for references and belongs_to columns" + + # creates the migration file for the model first followed by the model file itself + def create_migration_file return unless options[:migration] && options[:parent].nil? attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false @@ -39,6 +42,7 @@ module ActiveRecord protected + # Used by the migration template to determine the parent name of the model def parent_class_name options[:parent] || "ActiveRecord::Base" end -- cgit v1.2.3