2011-02-15 50 views
1

我已經設置了Devise需要的所有東西。事情對我來說工作得很好。
但有一兩件事很討厭:
當我要求通過該瀏覽器需要身份驗證的網頁(火狐)。它只是彈出一個警告對話框說:設計插件中的問題。 (Rails)


"A username and password are being requested by http://localhost:3001. The site says: "Application"' 

與用戶名和密碼輸入字段,而不是重定向到登錄頁面(「/ users/sign_in」頁面)。但即使無論輸入什麼用戶名和密碼,我都無法訪問(我可以通過「/ users/sign_in」使用相同的信息)。
幫助請:(


更新與我的模型:

class Account < ActiveRecord::Base 
    # Include default devise modules. Others available are: 
    # :token_authenticatable, :confirmable, :lockable and :timeoutable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :remember_me 
end 

我控制器(從腳手架生成):

class ThingsController < ApplicationController 
    before_filter :authenticate_account!, :except => ['show', 'index'] 
    # GET /things 
    # GET /things.xml 
    def index 
    @things = Thing.all 

    respond_to do |format| 
     format.html # index.html.erb 
     format.xml { render :xml => @things } 
    end 
    end 

    # GET /things/1 
    # GET /things/1.xml 
    def show 
    @thing = Thing.find(params[:id]) 

    respond_to do |format| 
     format.html # show.html.erb 
     format.xml { render :xml => @thing } 
    end 
    end 

    # GET /things/new 
    # GET /things/new.xml 
    def new 
    @thing = Thing.new 
.... 

,如果您需要更多信息,pl緩解讓我知道:)

+0

它看起來像您已啓用基本身份驗證。我不知道有足夠的設計給你一個關於如何禁用它的提示。 – Augusto 2011-02-15 16:55:10

+0

謝謝奧古斯托,幾乎解決了這個問題。我google搜索,但仍然沒有找到完美的解決方案,但找到這個:http://ewout.name/2010/04/http-basic-authentication-with-devise/但新的錯誤出現:「未初始化的常量Devise :: Strategies :: HttpAuthenticatable(NameError)「 – Croplio 2011-02-15 17:20:46

回答

0

我幾個星期前有這個問題。我忘記了我在哪裏找到了這個解決方案,但將下面的代碼行添加到我的設計初始化程序中爲我解決了這個問題。

# config/initializers/devise.rb 
config.navigational_formats = [:"*/*", :html]