尝试在Rails应用上发送消息时出现此错误。 请帮助我正确。 sessions.html.erb文件没有任何行36和38。这是错误:
语法错误,意外的keyword_end,期望为')' 结束 ^):app / views / private / conversations / _conversation.html.erb:36:语法 错误,意外的keyword_ensure,预期为')' app / views / private / conversations / _conversation.html.erb:38:语法 错误,意外的keyword_end,期望为')' app / views / private / conversations / _open.js.erb:10:in
_app_views_private_conversations__open_js_erb___4089549709349058989_70036360651440' app/views/assignments/show/contact_user/message_form/_success.js.erb:8:in
_ app_views_assignments_show_contact_user_message_form__success_js_erb__1046129379162570439_70036360658520' app / controllers / private / conversations_controller.rb:18:inblock (2 levels) in create' app/controllers/private/conversations_controller.rb:16:in
create'
我已经附加了控制器和_conversation.html.erb文件。我们将非常感谢您提供的任何帮助。谢谢
class Private::ConversationsController < ApplicationController
def create
recipient_id = Assignment.find(params[:assignment_id]).user.id
@conversation = Private::Conversation.new(sender_id: current_user.id,
recipient_id: recipient_id)
if @conversation.save
Private::Message.create(user_id: current_user.id,
conversation_id: @conversation.id,
body: params[:message_body])
add_to_conversations unless already_added?
respond_to do |format|
format.js { render partial: 'assignments/show/contact_user/message_form/success'}
end
else
respond_to do |format|
format.js {render partial: 'assignments/show/contact_user/message_form/fail'}
end
end
end
def close
@conversation_id = params[:id].to_i
session[:private_conversations].delete(@conversation_id)
respond_to do |format|
format.js
end
end
private
def add_to_conversations
session[:private_conversations] ||= []
session[:private_conversations] << @conversation.id
end
def already_added?
session[:private_conversations].include?(@conversation.id)
end
end
<% @recipient = private_conv_recipient(conversation) %>
<% @is_messanger = false %>
<li class="conversation-window"
id="pc<%= conversation.id>"
data-pconversation-user-name="<%= @recipient.name %>"
data-turbolinks-permanent>
<div class="panel panel-default" data-pconversation-id ="<%= conversation.id %>">
<%= render 'private/conversations/conversation/heading', conversation: conversation %>
<!-- Conversation window's content -->
<div class="panel-body">
<%= render 'private/conversations/conversation/messages_list', conversation: conversation %>
<%= render 'private/conversations/conversation/new_message_form', conversation: conversation, user: user %>
</div><!-- panel-body -->
</div>
</li><!-- conversation-window -->
答案 0 :(得分:6)
您忘记关闭标签
pc<%= conversation.id>