Class: PolylingoChat::Generators::ReadReceiptsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PolylingoChat::Generators::ReadReceiptsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/polylingo_chat/read_receipts/read_receipts_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
13 14 15 16 |
# File 'lib/generators/polylingo_chat/read_receipts/read_receipts_generator.rb', line 13 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end |
Instance Method Details
#copy_migration ⇒ Object
18 19 20 21 |
# File 'lib/generators/polylingo_chat/read_receipts/read_receipts_generator.rb', line 18 def copy_migration migration_template "create_message_read_receipts.rb", "db/migrate/create_polylingo_chat_message_read_receipts.rb" end |
#show_instructions ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/polylingo_chat/read_receipts/read_receipts_generator.rb', line 23 def show_instructions say "\n" + "=" * 80, :green say "Read receipts migration has been created!", :green say "=" * 80, :green say "\nNext steps:", :yellow say " 1. Run: rails db:migrate" say " 2. Messages will now automatically track read/unread status per participant" say "\nNew features available:", :cyan say " - Message model:" say " • message.mark_as_read_by(user)" say " • message.read_by?(user)" say " • message.unread_by?(user)" say " • message.read_at_by(user)" say " • Message.unread_by(user)" say " • Message.read_by(user)" say "\n - Conversation model:" say " • conversation.unread_messages_count_for(user)" say " • conversation.has_unread_messages_for?(user)" say "\n - Views automatically show:" say " • Read receipts (✓✓) on sent messages" say " • Unread message counts on conversation list" say "\n" end |