我在下面:The infamous RoR blog tutorial security section回報率:未定義的方法`http_basic_authenticate_with」
而且從試圖達到特定的相關頁面時,一些奇怪的原因,我得到一個:
undefined method 'http_basic_authenticate_with' for PostsController:Class
錯誤
我「M使用:
- 的Rails 3.0.9,
- RubyGems的1.8.11,
- 紅寶石1.9.2p290
任何想法可能會導致這樣或者一個特定的寶石,其缺什麼?控制器代碼的
部分:
class PostsController < ApplicationController
http_basic_authenticate_with :name => "dhh", :password => "secret",
:except => :index
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
format.json { render :json => @posts }
end
end
您可以發佈您的控制器代碼(或其中的部分)? – Nick
剛剛更新了文章 –
請記住,HTTP Auth-Basic是一個非常不安全的選項,您的密碼將通過網絡發送明文,用於每個請求。 – Jacco