Stack level too deep error in Ruby on Rails

后端 未结 8 2057
再見小時候
再見小時候 2020-12-16 11:00

I\'m having a stack level too deep error using Ruby 1.8.7 with Rails 3.0.4 and with the rails console I performed the following commands.



        
8条回答
  •  感情败类
    2020-12-16 11:47

    I had a "stack-level too deep" issue too. it was due to recursiveness in one of my functions and had been caused by a typo as you can see from below:

    def has_password?(submitted_password)
      encrypt_password == encrypt(submitted_password)
    end
    
    private
    
    def encrypt_password
      self.salt = make_salt unless has_password?(password)
      self.encrypted_password = encrypt(password)
    end
    

    I realised I had to change the second line to encrypted and it worked. Just checkout for recursion in your code it must be happening somewhere. Unfortunately I can't be of better use since I can't look at all your code files.

提交回复
热议问题