我有sync/booths/_chat_widget.html.haml
下的同步部分
聊天控制器和Booths控制器。
我的代码位于booths/show.html.haml
= sync partial: 'chat_widget', resource: @booth
这是:
#chat_widget{:title => "Booth chat", :style => "display:none;"}
.panel
.panel-body
%ul.chat
- @booth.chats.each do |chat|
= render partial: "chats/chat", locals: { chat: chat }
.panel-footer
= simple_form_for(@booth, url: chats_path, method: :post, remote: true) do |f|
.input-group
%input#chat-message.form-control.input-sm{name: "chat[message]", placeholder: "Type your message here...", type: "text"}
%input{type: "hidden", name: "chat[from_user_id]", value: "#{current_user.id}"}
%input{type: "hidden", name: "chat[chattable_id]", value: "#{@booth.id}"}
%input{type: "hidden", name: "chat[chattable_type]", value: "Booth"}
%span.input-group-btn
%button#btn-chat.btn.btn-warning.btn-sm{:type => 'submit'}
Send
= f.error_notification
这将使用以下代码创建Chats in Chats控制器:
def create
@chat = Chat.new(chat_params)
respond_to do |format|
if @chat.save
sync_update @chat
format.html{ redirect_to @chat, notice: 'Chat was successfully created.' }
format.js
else
format.html{ render action: 'new' }
format.js
end
end
end
然而,这似乎根本没有更新。这是因为它应该在sync/chat
文件夹下,因为主要的节目视图是在Booth下吗?