lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.2.21 vs lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.2.22
- old
+ new
@@ -666,10 +666,22 @@
parts = attribute.split(":")
name = parts.shift
type = parts.join(":")
boolean_buttons = type == "boolean"
+ if first_table_cell && ["trix_editor", "ckeditor", "text_area"].include?(type)
+ puts ""
+ puts "The first attribute of your model cannot be any of the following types:".red
+ puts "1. trix_editor"
+ puts "2. ckeditor"
+ puts "3. text_area"
+ puts ""
+ puts "Please ensure you have another attribute type as the first attribute for your model and try again."
+
+ exit
+ end
+
# extract any options they passed in with the field.
# will extract options declared with either [] or {}.
type, attribute_options = type.scan(/^(.*){(.*)}/).first || type
# create a hash of the options.
@@ -1521,9 +1533,15 @@
# add sortability.
if cli_options["sortable"]
unless cli_options["skip-model"]
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}")
+ 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-table"]
scaffold_replace_line_in_file("./app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb", transform_string("<tbody data-controller=\"sortable\" data-sortable-reorder-path-value=\"<%= url_for [:reorder, :account, context, collection] %>\">"), "<tbody>")
end