Class: Familyable::RelationshipsGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/generators/familyable/relationships_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_class_nameObject



17
18
19
20
21
# File 'lib/generators/familyable/relationships_generator.rb', line 17

def add_class_name
  unless options[:delete]
    gsub_file(relationship_model_path, "belongs_to :child", "belongs_to :child, class_name:\"#{clean_model_class_name}\"") 
  end
end

#generate_relationshipsObject



9
10
11
12
13
14
15
# File 'lib/generators/familyable/relationships_generator.rb', line 9

def generate_relationships
  if options[:delete]
    system("bundle exec rails d model #{clean_relationship_class_name}")
  else
    generate "model", "#{clean_relationship_class_name} #{clean_model_base_name}:references child:references"
  end
end