Class: ArMailerRevised::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/generators/ar_mailer_revised/install_generator.rb', line 10

def self.next_migration_number(path)
  if @prev_migration_nr
    @prev_migration_nr += 1
  else
    @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
  end
  @prev_migration_nr.to_s
end

Instance Method Details

#create_installObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/ar_mailer_revised/install_generator.rb', line 20

def create_install
  template 'model.rb', "app/models/#{model_name.classify.underscore}.rb"
  migration_template 'migration.rb', "db/migrate/create_#{model_name.classify.underscore.pluralize}.rb"

  initializer 'ar_mailer_revised.rb', <<INIT
ArMailerRevised.configuration do |config|

  #The model your application is using for email sending.
  #If you created it using the ArMailerRevised generator, the below
  #model name should already be correct.
  config.email_class = #{model_name}

end
INIT
end