我有mailboxer gem設置,當我訪問/對話時,我收到一個undefined method
參與者''錯誤指向與索引對話控制器。我向索引操作添加了一個會話實例變量,該變量將包含用戶的所有收件箱郵件。NoMethodError未定義的方法'參與者'
有人可以發現我的錯誤在我的定義?
對話控制器:
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 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
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
你會得到什麼確切的錯誤信息?一個完整的錯誤信息將包括接收者(例如,'undefined method'中的''foo'''for'foo':String')以及發生錯誤的文件和行號。 –
錯誤來自index,'@conversations || = current_user.mailbox.inbox.all'確切的錯誤信息是# NoMethodError –
xps15z
您好,您是否添加了'acts_as_messageable'你的用戶模型?另外,您是否手動創建對話模型?如果你這樣做,這可能是問題。郵箱安裝腳本應爲您處理該配置。 – winston