Class: Kablam::Generators::MessagingGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Kablam::Generators::MessagingGenerator
- Defined in:
- lib/generators/kablam/messaging_generator.rb
Instance Method Summary collapse
Instance Method Details
#setup_action_cable ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/kablam/messaging_generator.rb', line 9 def setup_action_cable inject_into_file 'app/assets/javascripts/application.js', after: "//= require_tree ." do "\n//= require cable" end inject_into_file 'config/routes.rb', before: 'end' do " mount ActionCable.server => '/cable'\n" end inject_into_file "app/views/layouts/application.html.erb", before: "</head>" do " <%= action_cable_meta_tag %>\n " end end |
#setup_assets ⇒ Object
32 33 34 35 36 |
# File 'lib/generators/kablam/messaging_generator.rb', line 32 def setup_assets inject_into_file 'app/assets/javascripts/application.js', before: "//= require_tree ." do "//= require kablam/messaging\n" end end |
#setup_models ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/kablam/messaging_generator.rb', line 21 def setup_models generate "model", "chat user:references subject:string " generate "model", "message chat:references content:text sender_id:integer attachment:string" generate "model", "message_status user:references message references read:boolean" copy_file "chat.rb", "app/models/chat.rb", force: true copy_file "message.rb", "app/models/message.rb", force: true status_migration = Dir.glob(Rails.root.to_s+"/db/migrate/**").last gsub_file status_migration, "t.boolean :read", "t.boolean :read, default: false" rake "db:migrate" end |