Sha256: 8b391214b8a2c60808ac409839097ae97cbb6704e51f233285dc371fb587e743
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
require 'rails/generators/active_record' class NotifyUser::InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path('../templates', __FILE__) def copy_migrations copy_migration "create_notify_user_notifications" copy_migration "create_notify_user_unsubscribes" copy_migration "create_notify_user_user_hashes" puts "Installation successful. You can now run:" puts " rake db:migrate" end def copy_initializer template "initializer.rb", "config/initializers/notify_user.rb" end def copy_notifications_controller template "notifications_controller.rb", "app/controllers/notify_user/notifications_controller.rb" end # 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. def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end protected def copy_migration(filename) if self.class.migration_exists?("db/migrate", "#{filename}") say_status("skipped", "Migration #{filename}.rb already exists") else migration_template "#{filename}.rb", "db/migrate/#{filename}.rb" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
notify_user-0.3.2 | lib/generators/notify_user/install/install_generator.rb |
notify_user-0.3.1 | lib/generators/notify_user/install/install_generator.rb |