Class: BallotBox::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/ballot_box/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_timeObject


25
26
27
28
# File 'lib/generators/ballot_box/install_generator.rb', line 25

def self.current_time
  @current_time ||= Time.now
  @current_time += 1.minute
end

.next_migration_number(dirname) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/generators/ballot_box/install_generator.rb', line 17

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    current_time.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#create_migrationsObject

copy migration files


13
14
15
# File 'lib/generators/ballot_box/install_generator.rb', line 13

def create_migrations
  migration_template "migrate/create_votes.rb", File.join('db/migrate', "ballot_box_create_votes.rb")
end