Search code examples
ruby-on-railsruby-on-rails-3devisestackstack-overflow

Devise stack level too deep error


After install Devise I try to run

**rake db:migrate**

but it gives:

**rake aborted!
stack level too deep**

I'm on Ubuntu, changed

**ulimit -s unlimited**

and checked, it works, but still have the error.

I use RVM, tried to work out with Ruby1.9.2-p180, Ruby-1.9.2-p0, with Rails 3.0.9, Rails 3.1rc4, with Rubinius. Tried with SQLite3 and with PostgreSQL. Tried to uncomment as many as I can from the migration file.

Read all related Stackoverflow posts (and realized what I have is actually named StackOverflow).

Any help would be highly appriaciated! Many thanks


Solution

  • stack level too deep errors typically result from infinite recursion problems.

    New Answer:

    I forgot this was occurring during db:migrate. Is something in your users table migration relying on something that would rely on it?

    Old Answer:

    It would be helpful for you to show the lines of code you have in your routes.rb file for devise. For example, you might have:

    devise_for :users, :controllers => { :registrations => "registration/foo" }
    

    In this example, take a look at the new method in foo_controller.rb. If that method redirects to another controller that causes you to attempt to register again, you will have an infinite recursion.

    The first thing I would do is look at what controllers are being called by putting some sort of debug output in your controllers. Try:

    logger.debug("i am in foo")
    

    or

    puts "i am in bar"
    

    If you can provide more information, I may be able to help more.