ruby on rails - Devise User Stack Level Too Deep Error - Possibly due to this added Username funcitonality -
when try access current_user
via devise...
def current_user @user = user.find(current_user.id) @user end
and render of attributes in json via rabl template...
object @user attributes :email, :username
i error...
systemstackerror @ /api/current_user stack level deep
i think error due within user model, modified add in username field. followed devise's instructions here add functionality...
class user < activerecord::base # include default devise modules. others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable , :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :login, :username, :email, :password, :password_confirmation, :remember_me has_many :cart_items, dependent: :destroy # virtual attribute authenticating either username or email # in addition real persisted field 'username' attr_accessor :login def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) where(conditions).where(["lower(username) = :value or lower(email) = :value", { :value => login.downcase }]).first else where(conditions).first end end end
you calling current_user within current_user...
def current_user @user = user.find(current_user.id) ^^^^
it calls itself, calls again, , again... until stack overflow
i'm not sure you seem need re-write current_user method. afaik devise you. can show me in tutorial says rewrite def current_user
?
Comments
Post a Comment