Class: LoyaltyRef::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/loyalty_ref/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_user_model_methodsObject



22
23
24
25
26
27
# File 'lib/generators/loyalty_ref/install/install_generator.rb', line 22

def add_user_model_methods
  user_class = ask("What is your user model class name? (default: User)")
  user_class = "User" if user_class.blank?

  template "user_model.rb", "app/models/#{user_class.downcase}.rb", force: true
end

#add_user_model_migrationObject



14
15
16
17
18
19
20
# File 'lib/generators/loyalty_ref/install/install_generator.rb', line 14

def add_user_model_migration
  generate_migration = ask("Would you like to add referral_code and tier columns to your User model? (y/n)")
  
  if generate_migration.downcase == "y"
    generate "migration", "AddLoyaltyRefToUsers referral_code:string tier:string"
  end
end

#create_initializerObject



10
11
12
# File 'lib/generators/loyalty_ref/install/install_generator.rb', line 10

def create_initializer
  template "initializer.rb", "config/initializers/loyalty_ref.rb"
end

#show_instructionsObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/loyalty_ref/install/install_generator.rb', line 29

def show_instructions
  puts "\n" + "="*60
  puts "🎉 LoyaltyRef has been installed successfully!"
  puts "="*60
  puts "\nNext steps:"
  puts "1. Run: rails db:migrate"
  puts "2. Customize config/initializers/loyalty_ref.rb"
  puts "3. Access admin dashboard at: /loyalty"
  puts "\nFor more information, visit: https://github.com/rails_to_rescue/loyalty_ref"
  puts "="*60
end