Issues in Devise plugin. (Rails)
I have set up all things that the Devise needs. And things works fine for me.
But there is one thing very annoying: When I request the pages which need authentication through the browser(Firefox).It just pop out an alert dialog says:"A username and password are being requested by http://localhost:3001. The site says: "Application"'
with the user name and password input fields instead of redirecting to the login page (the "/users/sign_in" page).But even, whatever user name and password I typed in, I just can't access (I can successfully login through the "/users/sign_in" with the same info).
Help please :(Update with my model:
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
My controller (generated from the scaffold):
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
....
if you need more information, please 开发者_Go百科let me know :)
I had this issue a few weeks ago. I forget where I found this solution, but adding the following line to my devise initializer took care of the problem for me.
# config/initializers/devise.rb
config.navigational_formats = [:"*/*", :html]
精彩评论