Class: Testimonials::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



31
32
33
# File 'lib/generators/testimonials/install/install_generator.rb', line 31

def create_initializer
  template 'initializer.rb.tt', 'config/initializers/testimonials.rb'
end

#create_migration_fileObject



35
36
37
38
# File 'lib/generators/testimonials/install/install_generator.rb', line 35

def create_migration_file
  migration_template 'create_testimonials_tables.rb.tt',
                     'db/migrate/create_testimonials_tables.rb'
end

#mount_engineObject



40
41
42
# File 'lib/generators/testimonials/install/install_generator.rb', line 40

def mount_engine
  route %(mount_testimonials at: "/testimonials")
end

#post_installObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/testimonials/install/install_generator.rb', line 44

def post_install
  say "\ntestimonials installed. Run `rails db:migrate`, then add", :green
  say '`<%= testimonials_tag %>` before </body> in your layout.'
  say 'Triage testimonials at /testimonials (development only until you set config.authorize_admin).'
  samples = options[:skip_nps] ? 'testimonials' : 'testimonials and NPS'
  say "Optional: run `bin/rails testimonials:seed_demo` for sample #{samples}."
  say "Collect from outside the app via /testimonials/new.\n"

  if options[:skip_nps]
    say 'Installed without NPS. Add it later with `bin/rails generate testimonials:nps`.', :yellow
  end

  return unless options[:skip_prompt_events]

  say 'Installed without prompt history, so testimonial_prompt! will not auto-open the ' \
      'widget — open it from your own button. Add it later with ' \
      '`bin/rails generate testimonials:prompt_events`.', :yellow
end