我已经设置了Devise需要的所有东西。对我来说,事情很好
但有一件事非常烦人:
当我通过浏览器(Firefox)请求需要身份验证的页面时。它只是弹出一个警告对话框说:
"A username and password are being requested by http://localhost:3001. The site says: "Application"'
使用用户名和密码输入字段而不是重定向到登录页面(" / users / sign_in"页面)。但是,即使我输入的用户名和密码,我也可以&# 39; t access(我可以成功登录" / 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
....
如果您需要更多信息,请告诉我们:)
答案 0 :(得分:0)
# config/initializers/devise.rb
config.navigational_formats = [:"*/*", :html]