Class: Rails::Generators::ChannelGenerator

Inherits:
NamedBase show all
Defined in:
actioncable/lib/rails/generators/channel/channel_generator.rb

Instance Method Summary collapse

Methods inherited from NamedBase

#initialize

Methods inherited from Base

base_root, class_option, default_source_root, desc, hide!, hook_for, inherited, namespace, remove_hook_for, source_root

Methods included from Actions

#add_source, #after_bundle, #capify!, #environment, #gem, #gem_group, #generate, #git, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

This class inherits a constructor from Rails::Generators::NamedBase

Instance Method Details

#create_channel_fileObject


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'actioncable/lib/rails/generators/channel/channel_generator.rb', line 12

def create_channel_file
  template "channel.rb", File.join('app/channels', class_path, "#{file_name}_channel.rb")

  if options[:assets]
    if self.behavior == :invoke
      template "assets/cable.js", "app/assets/javascripts/cable.js"
    end

    js_template "assets/channel", File.join('app/assets/javascripts/channels', class_path, "#{file_name}")
  end

  generate_application_cable_files
end