Class: NotifyUser::JsonUpdateGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/notify_user/json_update/json_update_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

This is defined in ActiveRecord::Generators::Base, but that inherits from NamedBase, so it expects a name argument which we don’t want here. So we redefine it here. Yuck.



18
19
20
21
22
23
24
# File 'lib/generators/notify_user/json_update/json_update_generator.rb', line 18

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

Instance Method Details

#copy_migrationsObject



8
9
10
11
12
13
14
# File 'lib/generators/notify_user/json_update/json_update_generator.rb', line 8

def copy_migrations
  copy_migration "add_json_column_to_notifications"
  copy_migration "move_params_to_json"

  puts "Installation successful. You can now run:"
  puts "  rake db:migrate"
end