class LocalizableDb::Generators::ModelGenerator
Public Instance Methods
create_migration_file()
click to toggle source
# File lib/generators/localizable_db/model_generator.rb, line 19 def create_migration_file return unless options[:migration] && options[:parent].nil? attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[: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()
click to toggle source
# 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