SystemStackError in Rails::ActiveSupport::Callbacks

Posted by coreyward on Stack Overflow See other posts from Stack Overflow or by coreyward
Published on 2011-01-03T20:51:16Z Indexed on 2011/01/03 20:53 UTC
Read the original article Hit count: 232

I'm building a Rails app that connects to Dropbox and syncs with a folder to update a personal site. I'm using Rails 3.0.3, Ruby 1.9.2, and the Dropbox gem. Right now I have a DropboxAccounts Controller, and two models: DropboxSession, which wraps calls to the gem with application-specific functionality, and DropboxAccount, which stores the session and settings in the database.

After the user authorizes their account with Dropbox they're redirected back over and the DropboxAccount is saved with the authorized session. That all works just fine. My problem is that when I try to call Dropbox::API#create_folder(any path) I end up with a SystemStackError in lib/activesupport/callbacks.rb:421 which refers to the code below. If I remove the call to create the folder, it works. If I call create folder from another request, it works. I doubled the stack size to 16K to no avail.

# This is called the first time a callback is called with a particular
# key. It creates a new callback method for the key, calculating
# which callbacks can be omitted because of per_key conditions.
#
def __create_keyed_callback(name, kind, object, &blk) #:nodoc:
  @_keyed_callbacks ||= {}
  @_keyed_callbacks[name] ||= begin
    str = send("_#{kind}_callbacks").compile(name, object)
    class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
      def #{name}() #{str} end   # THIS IS LINE 421
      protected :#{name}
    RUBY_EVAL
    true
  end
end

I'm not very familiar with Rails yet, and I'm not sure what the intention of the code above is or why it would cause a stack overflow. I'm not using any method_missing/ghost method magic in my code. I suspected it was something with a callback serialize :files but commenting it out did nothing. My DropboxAccount model contains only a call to belongs_to :user, and DropboxSession is just a handful of methods, none of which contain callbacks. Bypassing them and using the Dropbox::Session methods directly doesn't help.

I hope someone on StackOverflow can help me with this stack overflow. ;)

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby