0

メールボックスの 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'

私が間違っていることをアドバイスしてください。私は1日以来それに取り組んできましたが、それに対する解決策が見つかりませんでした。言うまでもなく、userAとuserBは両方とも異なるデバイスユーザーです。それに関する提案は大歓迎です。

4

1 に答える 1

0

pathから取得できる in リダイレクトを使用してみてくださいrake_routes。おそらく、以下に示す例がうまくいくでしょう。

respond_to do |format|
    format.html { redirect_to inbox_path, notice: 'Conversation successfully trashed.' }    
end
于 2014-08-27T15:08:01.363 に答える