Class: Chats::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Chats::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/chats/install_generator.rb
Overview
‘rails generate chats:install` — copies the adaptive migration (uuid or bigint keys, adapter-aware JSON columns) and the annotated initializer, then prints the remaining setup steps.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dir) ⇒ Object
17 18 19 |
# File 'lib/generators/chats/install_generator.rb', line 17 def self.next_migration_number(dir) ActiveRecord::Generators::Base.next_migration_number(dir) end |
Instance Method Details
#create_initializer ⇒ Object
25 26 27 |
# File 'lib/generators/chats/install_generator.rb', line 25 def create_initializer template "initializer.rb", "config/initializers/chats.rb" end |
#create_migration_file ⇒ Object
21 22 23 |
# File 'lib/generators/chats/install_generator.rb', line 21 def create_migration_file migration_template "create_chats_tables.rb.erb", File.join(db_migrate_path, "create_chats_tables.rb") end |
#display_post_install_message ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/chats/install_generator.rb', line 29 def say "\n💬 The `chats` gem has been installed.", :green say "\nTo complete the setup:" say " 1. Run 'rails db:migrate' to create the chats tables." say " ⚠️ You must run migrations before starting your app!", :yellow say " 2. Make your users conversational:" say " class User < ApplicationRecord" say " acts_as_messager" say " end" say " 3. Mount the inbox wherever you want it to live:" say " # config/routes.rb" say " mount Chats::Engine => \"/messages\"" say " 4. (Optional) Attach conversations to your domain:" say " class Ride < ApplicationRecord" say " acts_as_chat_subject" say " end" say " user.chat_with(driver, about: ride)" say "\nYou now have real-time DMs: inbox, threads, reactions, read receipts. 🚀" say "Pure Hotwire — works out of the box with importmaps + the default Stimulus setup.\n", :green end |