0

I am getting the error Mongoid::Errors::DocumentNotFound in UsersController#show whenever I am trying to click on signout in my app which uses mongoid rails 4.0.1 and devise.

My user controller code is

class UsersController < ApplicationController
  before_filter :authenticate_user!

  def index

    @users = User.all
  end

  def show

    @user = User.find(params[:id])
  end

end

The error is:

Problem: Document(s) not found for class User with id(s) sign_out. Summary: When calling User.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): sign_out ... (1 total) and the following ids were not found: sign_out. Resolution: Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.

Please help me in this issue.

Mike Vormwald
  • 2,280
  • 22
  • 29
user2853838
  • 31
  • 1
  • 6

1 Answers1

0

A similar question, is here.

While all the first answer is important and needs to be checked (make sure you have :method => :delete on your 'Sign Out' link), it is the third answer which fixed it for my Rails 4.1.6 + Mongoid app: adding jquery_ujs.

Specifically, adding //= require jquery_ujs to my application.js file took my broken link and made it sign out sucessfully.

Community
  • 1
  • 1
pgarber
  • 7
  • 2