Class: Chat::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Chat::Generators::InstallGenerator
show all
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/chat/install/install_generator.rb
Defined Under Namespace
Classes: UsersTableNotImplemented
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
55
56
57
|
# File 'lib/generators/chat/install/install_generator.rb', line 55
def self.next_migration_number(dirname)
ActiveRecord::Generators::Base.next_migration_number(dirname)
end
|
Instance Method Details
#add_chat_route ⇒ Object
45
46
47
|
# File 'lib/generators/chat/install/install_generator.rb', line 45
def add_chat_route
route "mount Chat::Engine => \"/chat\", as: \"chat\""
end
|
#add_chat_status_migration ⇒ Object
39
40
41
42
43
|
# File 'lib/generators/chat/install/install_generator.rb', line 39
def add_chat_status_migration
migration_template "add_chat_to_users.rb",
"db/migrate/add_chat_to_users.rb"
migration_template "create_chat.rb", "db/migrate/create_chat.rb"
end
|
#add_helper ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/generators/chat/install/install_generator.rb', line 23
def add_helper
file = "app/controllers/application_controller.rb"
after = "class ApplicationController < ActionController::Base\n"
inject_into_file file, after: after do
" helper Chat::Engine.helpers\n"
end
end
|
#check_user_table ⇒ Object
15
16
17
|
# File 'lib/generators/chat/install/install_generator.rb', line 15
def check_user_table
raise UsersTableNotImplemented unless users_table_exists?
end
|
#create_chat_initializer ⇒ Object
19
20
21
|
# File 'lib/generators/chat/install/install_generator.rb', line 19
def create_chat_initializer
copy_file "chat.rb", "config/initializers/chat.rb"
end
|
#inject_chat_into_user_model ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/generators/chat/install/install_generator.rb', line 31
def inject_chat_into_user_model
file = "app/models/user.rb"
after = "class User < ApplicationRecord\n"
inject_into_file file, after: after do
" include Chat::User\n"
end
end
|