diff options
author | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-05-14 00:27:52 +0530 |
---|---|---|
committer | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-05-14 00:27:52 +0530 |
commit | 87d71b02b85a44ce461e533666ef5f0e43a46531 (patch) | |
tree | 8f525e54c818bed82e486adfff97489e5780f530 /activerecord/lib/rails | |
parent | af2d212b63d5af09044d30e3dfbaec8b31f26fd7 (diff) | |
download | rails-87d71b02b85a44ce461e533666ef5f0e43a46531.tar.gz rails-87d71b02b85a44ce461e533666ef5f0e43a46531.tar.bz2 rails-87d71b02b85a44ce461e533666ef5f0e43a46531.zip |
Added documentation for model migration generation
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/model_generator.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |