我有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