1

我目前在 Rails 3 项目中使用 Private Pub 时遇到问题。所有示例都显示了发布/订阅这样的路由的用法: “/messages/new” 但是如果预期的路由更复杂一点,即。

路线.rb

resources :messages, only: [] do
  post 'chat', on: :member  
end

这将创建以下内容

chat_message POST /messages/:id/chat(.:format) messages#chat

因此,我这样使用它:

看法:

= subscribe_to "/messages/#{@cid}/chat"

咖啡响应视图:

<% publish_to "/messages/#{current_user.convos.first.id}/chat" do %>
$('#message-display').append("<%= j render partial: 'shared/single_message', locals: { user: current_user } %>")
<% end %>

但是该块永远不会被触发!应该是同一条路线吧?我的意思是,段键匹配......它根本不会在任何视图中工作,块内的代码永远不会到达。我究竟做错了什么?

请帮我!

何塞。

笔记。我看到的所有示例似乎都展示了使用此 gem 进行一般聊天。我的目的是为各种点对点私人对话创建各种渠道(如 Facebook 聊天)

4

1 回答 1

2

CoffeeScript 不处理 ruby​​ 块。它们是红宝石块。而且您不能在 views/ 文件夹中链接扩展。

于 2013-06-24T15:05:32.893 回答