跳至内容 跳至搜索
方法
C

实例公共方法

channel_name()

返回通道的名称,使用下划线分隔,不包含Channel后缀。如果通道位于命名空间中,则命名空间将以单个冒号分隔符表示在通道名称中。

ChatChannel.channel_name # => 'chat'
Chats::AppearancesChannel.channel_name # => 'chats:appearances'
FooChats::BarAppearancesChannel.channel_name # => 'foo_chats:bar_appearances'
# File actioncable/lib/action_cable/channel/naming.rb, line 18
def channel_name
  @channel_name ||= name.delete_suffix("Channel").gsub("::", ":").underscore
end