devise in rails 3 : 'user_signed_in?' false 'signed_in?' true 'current_user' nil -
i migrating rails 2 app rails 3 , had use new authentication solution since restful_authentication no longer supported. trying out devise , having problems it.
i have login page, directs app. can use app without logging in options not available until login.
once logging in devise says have logged in via flash message, current_user
evaluate nil
, current_user.blank?
evaluates true
, user_signed_in?
evaluate false
. oddly signed_in?
evaluates true
. checking session data shows warden.user.user.id
contains correct user id , csrf token exists. true both in view , in controller.
here routes.rb
myapp::application.routes.draw devise_for :users match "/:controller(/:action(/:id))" match "/:controller(/:action(/:id))(.:format)" match "/:controller(/:action(.:format))" devise_scope :user 'signup', :to => 'devise/registrations#new' 'login', :to => 'devise/sessions#new' 'signout', :to => 'devise/sessions#destroy' end root :to => 'main#design' end
user.rb
require 'digest/sha1' class user < activerecord::base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :confirmable, :validatable, :encryptable, :encryptor => :restful_authentication_sha1 attr_accessible :email, :password, :password_confirmation, :remember_me, :profile_company, :profile_state, :profile_city, :profile_postcode, :profile_country, :profile_phone, :profile_address validates_length_of :name, :maximum => 100 validates_presence_of :email validates_length_of :email, :within => 6..100 validates_uniqueness_of :email def profile_complete? if !(self.profile_address.blank? || self.profile_city.blank? || self.profile_state.blank? || self.profile_phone.blank? || self.name.blank? || self.state != 'active') true else false end end end
i've seen lot of similar questions on so, none of answers seem fit scenario. appreciated, thanks!
edit: warden.authenticate(:scope => :user)
returns expect current_user
return.
i believe have solved issue, restful_authentication plugin added usershelper file believe somehow interfering how devise handling user class.
Comments
Post a Comment