Class: Adminpanel::MigrationGenerator
Instance Method Summary
collapse
#migration_name, #resource_migrating
#assign_attributes_variables, #associations, #attribute_hash, #belongs_to_association, #belongs_to_field, #belongs_to_form_hash, #boolean_form_hash, #camelized_resource, #checkbox_association, #checkbox_field, #checkbox_form_hash, #class_name, #date_form_hash, #file_association, #file_field_form_hash, #file_form_hash, #float_form_hash, #form_attributes_hash, #form_type, #gallery_name, #has_associations?, #has_gallery?, #image_form_hash, #integer_form_hash, #is_a_resource?, #label_type, #model_type, #needs_name?, #placeholder_type, #pluralized_name, #resource_class_name, #resource_name, #string_form_hash, #symbolized_attributes, #text_form_hash
Instance Method Details
#change_field_aliases ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/adminpanel/migration/migration_generator.rb', line 14
def change_field_aliases
fields.each do |attribute|
type = attribute.split(':').second
case type
when 'wysiwyg'
fields.delete(attribute)
fields << attribute.split(':').first + ':' + 'text'
end
end
end
|
#generate_migration ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/generators/adminpanel/migration/migration_generator.rb', line 25
def generate_migration
parameters = fields
parameters.delete_if do |pair|
if pair.split(':').second == 'has_many'
puts "migrations aren't supported yet, sorry :(, but you can do a pull request"
true
else
false
end
end
invoke :migration, [migration_name, parameters]
end
|
#inject_attributes_into_file ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/generators/adminpanel/migration/migration_generator.rb', line 38
def inject_attributes_into_file
inject_into_file(
"app/models/adminpanel/#{resource_migrating}.rb",
after: ' ['
) do
indent ("\n" + form_attributes_hash + ','), 8
end
end
|
#puts_messages ⇒ Object
47
48
49
|
# File 'lib/generators/adminpanel/migration/migration_generator.rb', line 47
def puts_messages
puts "don't forget to migrate your database"
end
|