In order to require an http connection to authenticate using HTTP Digest in Rails, execute the following code:

# ... ApplicationController class
private  
	DUsers = {"user" => "password"}  
	def digest_authenticate  
		realm = "application"  
		authenticate_or_request_with_http_digest(realm) do |name|  
		DUsers[name]  
	end  
end  

… and execute this code before the invocation to our controller endpoint:

 class ExampleController < ApplicationController  
 before_filter :digest_authenticate, :only => ['index']  

 	def index  
 	end  
 end