Class: Moderate::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Moderate::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/moderate/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dir) ⇒ Object
14 15 16 |
# File 'lib/generators/moderate/install_generator.rb', line 14 def self.next_migration_number(dir) ActiveRecord::Generators::Base.next_migration_number(dir) end |
Instance Method Details
#create_initializer ⇒ Object
22 23 24 |
# File 'lib/generators/moderate/install_generator.rb', line 22 def create_initializer template "initializer.rb", "config/initializers/moderate.rb" end |
#create_migration_file ⇒ Object
18 19 20 |
# File 'lib/generators/moderate/install_generator.rb', line 18 def create_migration_file migration_template "create_moderate_tables.rb.erb", File.join(db_migrate_path, "create_moderate_tables.rb") end |
#display_post_install_message ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/moderate/install_generator.rb', line 26 def say "\n🛡️ The `moderate` gem has been installed.", :green say "\nTo complete the setup:" say " 1. Run 'rails db:migrate' to create the moderation tables." say " ⚠️ You must run migrations before starting your app!", :yellow say " 2. Tell `moderate` who your users are in config/initializers/moderate.rb:" say " config.user_class = \"User\"" say " 3. Add the mixins to your models:" say " class User < ApplicationRecord" say " include Moderate::Actor # can report, block, and be blocked" say " end" say "" say " class Message < ApplicationRecord" say " include Moderate::Reportable # can be reported" say " moderates :body # and filtered before save" say " end" say "\nYou now have reporting, blocking, filtering, and a moderation queue. 🚀\n", :green end |