class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
end

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  rescue_from ActiveRecord::RecordNotFound do
    respond_to do |type|
      type.all {render :nothing => true, :status => 404}
    end
  end
end

Add rescue from record not found clause
Add rescue from record not found clause

This will make the app return 404 when user tries
to act on non-existing id
