lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.7.3 vs lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.7.9
- old
+ new
@@ -1349,11 +1349,11 @@
# find the database migration that defines this relationship.
migration_file_name = `grep "create_table :#{class_names_transformer.table_name}.*do |t|$" db/migrate/*`.split(":").first
unless migration_file_name.present?
raise "No migration file seems to exist for creating the table `#{class_names_transformer.table_name}`.\n" \
"Please run the following command first and try Super Scaffolding again:\n" \
- "rails generate model #{child} #{parent.downcase!}:references #{attributes.join(" ")}"
+ "rails generate model #{child} #{parent.underscore}:references #{attributes.join(" ")}"
end
# if needed, update the reference to the parent class name in the create_table migration
current_transformer = Scaffolding::ClassNamesTransformer.new(child, parent, namespace)
unless current_transformer.parent_variable_name_in_context.pluralize == current_transformer.parent_table_name
@@ -1456,10 +1456,10 @@
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "def collection\n absolutely_abstract_creative_concept.completely_concrete_tangible_things\nend\n\n", METHODS_HOOK, prepend: true)
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "include Sortable\n", CONCERNS_HOOK, prepend: true)
migration = Dir.glob("db/migrate/*").last
migration_lines = File.open(migration).readlines
- parent_line_idx = Scaffolding::FileManipulator.find(migration_lines, "t.references :#{parent.downcase}")
+ parent_line_idx = Scaffolding::FileManipulator.find(migration_lines, "t.references :#{parent.underscore}")
new_lines = Scaffolding::BlockManipulator.insert_line("t.integer :sort_order", parent_line_idx, migration_lines, false)
Scaffolding::FileManipulator.write(migration, new_lines)
end
unless cli_options["skip-controller"]