Class: LocalizableDb::Generators::ModelGenerator
- Inherits:
-
ActiveRecord::Generators::ModelGenerator
- Object
- ActiveRecord::Generators::ModelGenerator
- LocalizableDb::Generators::ModelGenerator
- Includes:
- OrmHelper
- Defined in:
- lib/generators/localizable_db/model_generator.rb
Instance Method Summary collapse
Methods included from Languages
Instance Method Details
#create_migration_file ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/localizable_db/model_generator.rb', line 19 def create_migration_file return unless [:migration] && [:parent].nil? attributes.each { |a| a..delete(:index) if a.reference? && !a.has_index? } if [:indexes] == false model_template = "#{__FILE__}/../templates/create_table_migration.rb" model_migration_name = "db/migrate/create_#{table_name}.rb" migration_template( model_template, model_migration_name, migration_version: migration_version ) end |
#generate_migration_for_localizable ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/generators/localizable_db/model_generator.rb', line 36 def generate_migration_for_localizable case behavior when :invoke invoke( "localizable_db:migration", [ table_name.singularize.camelize ] + attributes.map { |attribute| if attribute.type.eql? :string "#{attribute.name}:#{attribute.type.to_s}" end } ) when :revoke invoke( "localizable_db:migration", [ table_name ], behavior: :revoke ) end end |