class ActiveRecord::Generators::GrapeBunchGenerator
Public Instance Methods
copy_grape_bunch_migration()
click to toggle source
# File lib/generators/active_record/grape_bunch_generator.rb, line 13 def copy_grape_bunch_migration if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name)) migration_template "migration_existing.rb", "db/migrate/add_grape_bunch_to_#{table_name}.rb", migration_version: migration_version else migration_template "migration.rb", "db/migrate/grape_bunch_create_#{table_name}.rb", migration_version: migration_version end end
generate_model()
click to toggle source
# File lib/generators/active_record/grape_bunch_generator.rb, line 21 def generate_model invoke "active_record:model", [name], migration: false unless model_exists? && behavior == :invoke end
migration_data()
click to toggle source
# File lib/generators/active_record/grape_bunch_generator.rb, line 25 def migration_data <<RUBY t.string :email, null: false, default: "" RUBY end
migration_version()
click to toggle source
# File lib/generators/active_record/grape_bunch_generator.rb, line 36 def migration_version if rails5? "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end
rails5?()
click to toggle source
# File lib/generators/active_record/grape_bunch_generator.rb, line 31 def rails5? Rails.version.start_with? '5' end