Permalink
Browse files

Added documentation for model migration generation

  • Loading branch information...
1 parent af2d212 commit 87d71b02b85a44ce461e533666ef5f0e43a46531 @aditya-kapoor aditya-kapoor committed May 13, 2013
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/rails/generators/active_record/model/model_generator.rb
@@ -12,6 +12,9 @@ class ModelGenerator < Base # :nodoc:
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 @@ def accessible_attributes
protected
+ # Used by the migration template to determine the parent name of the model
def parent_class_name
options[:parent] || "ActiveRecord::Base"
end

0 comments on commit 87d71b0

Please sign in to comment.