我一直面临着邮箱 gem 的一些问题。特别是回复和垃圾箱,回复邮件并选择删除时也会发送到垃圾箱,但这样做后我无法成功地将其重定向到收件箱。我总是不断收到错误“找不到具有 id 的用户”以下是垃圾部分的控制器代码 -
def trash
conversation = Conversation.find(params[:id])
beta = current_userA || current_userB
case beta
when current_userA
conversation.move_to_trash(current_userA)
# redirect_to :conversations
when current_userB
conversation.move_to_trash(current_userB)
# redirect_to :conversations
end
respond_to do |format|
format.html { redirect_to conversation_path, notice: 'Conversation successfully trashed.' }
end
end
日志
Started GET "/conversations/36" for 127.0.0.1 at 2014-08-28 10:19:56 +0530
Processing by ConversationsController#show as HTML
Parameters: {"id"=>"36"}
Message Load (0.5ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."type" IN ('Message') AND "notifications"."id" = $1 LIMIT 1 [["id", "36"]]
Conversation Load (0.4ms) SELECT "conversations".* FROM "conversations" WHERE "conversations"."id" = 34 LIMIT 1
Completed 404 Not Found in 4ms
ActiveRecord::RecordNotFound (Couldn't find userA without an ID):
app/controllers/conversations_controller.rb:160:in `show'
Rendered /usr/local/rvm/gems/ruby-1.9.3-p545/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p545/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p545/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (19.7ms)
更新日志
使用 redirect_to 对话更改 redirect_to 对话后
Started POST "/conversations/38/trash" for 127.0.0.1 at 2014-08-28 12:29:16 +0530
Processing by ConversationsController#trash as HTML
Parameters: {"authenticity_token"=>"CuXzMKNmD87qvfOuer4uhyTdysFS/5NxtfMZU3/Y5j0=", "id"=>"38"}
Conversation Load (0.4ms) SELECT "conversations".* FROM "conversations" WHERE "conversations"."id" = $1 LIMIT 1 [["id", "38"]]
Filmmaker Load (0.7ms) SELECT "userA".* FROM "userA" WHERE "userA"."id" = 67 LIMIT 1
Receipt Load (0.8ms) SELECT "receipts".* FROM "receipts" INNER JOIN "notifications" ON "notifications"."id" = "receipts"."notification_id" AND "notifications"."type" IN ('Message') WHERE "notifications"."conversation_id" = 38 AND "receipts"."receiver_id" = 67 AND "receipts"."receiver_type" = 'userA'
SQL (11.3ms) UPDATE "receipts" SET "trashed" = 't' WHERE (id = 82 )
User Load (29.7ms) SELECT "users".* FROM "users"
Completed 500 Internal Server Error in 110ms
NameError (undefined local variable or method `conversations' for #<ConversationsController:0x10961634>):
app/controllers/conversations_controller.rb:101:in `block (2 levels) in trash'
app/controllers/conversations_controller.rb:100:in `trash'
请告诉我我做错了什么,我从一天开始就一直在做,但我还没有找到任何解决方案。不用说,userA 和 userB 都是不同的设计用户。任何关于它的建议都是最受欢迎的。