Skip to content

Commit

Permalink
Added documentation for model migration generation
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-kapoor committed May 13, 2013
1 parent af2d212 commit 87d71b0
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 87d71b0

Please sign in to comment.