0
我有郵箱gem安裝,我正在配置它。我一直試圖設置它,但是當我訪問/對話時,我得到一個SyntaxError unexpected tIDENTIFIER, expecting keyword_end
語法錯誤,意外tidENTIFIER,期待keyword_end對話控制器
我似乎無法看到我出錯了,因爲有原始代碼的修改。
class ConversationsController < ApplicationController
helper_method :mailbox, :conversation
def index
@conversations ||= current_user.mailbox.inbox.all
end
def reply
current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
redirect_to conversation
end
def trash_folder
@trash ||= current_user.mailbox.trash.all
end
def trash
conversation.move_to_trash(current_user)
redirect_to :conversations
end
def untrash
conversation.untrash(current_user)
redirect_to :back
end
def empty_trash current_user.mailbox.trash.each do |conversation| conversation.receipts_for(current_user).update_all(:deleted => true)
end
redirect_to :conversations
end
def create
recipient_emails = conversation_params(:recipients).split(',')
recipients = User.where(email: recipient_emails).all
conversation = current_user.
send_message(recipients, *conversation_params(:body, :subject)).conversation
redirect_to conversation
end
def reply
current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
redirect_to conversation
end
def trash
conversation.move_to_trash(current_user)
redirect_to :conversations
end
def untrash
conversation.untrash(current_user)
redirect_to :conversations
end
private
def mailbox
@mailbox ||= current_user.mailbox
end
def conversation
@conversation ||= mailbox.conversations.find(params[:id])
end
def conversation_params(*keys)
fetch_params(:conversation, *keys)
end
def message_params(*keys)
fetch_params(:message, *keys)
end
def fetch_params(key, *subkeys)
params[key].instance_eval do
case subkeys.size
when 0 then self
when 1 then self[subkeys.first]
else subkeys.map{|k| self[k] }
end
end
end
路線:
resources :users do |user|
end
resources :messages do
member do
post :new
end
end
resources :conversations do
member do
post :reply
post :trash
post :untrash
end
collection do
get :trashbin
post :empty_trash
end
end
如果你排列你的代碼並正確縮進它,那會很好。這個錯誤是因爲你有或缺少一個額外的'結束'或一個不匹配的結束。我會假設是在這部分'def empty_trash current_user.mailbox.trash.each do | conversation | conversation.receipts_for(current_user).update_all(:deleted => true) end redirect_to:對話 end'。 發佈整個堆棧跟蹤將幫助更多。 –