1

I'm in the process of ugrading my Rails 3.2 app to Rails 4.1. (I'm using rbx-2.2.10)

I've got to the stage where I'm running my specs, but they fail whenever they query the db and I get this error:

LocalJumpError: unexpected return

I tried to investigate in my console and I get the same issue when running a query.

I have read a few answers such as this one:

Unexpected Return (LocalJumpError)

about rails not allowing return calls inside of blocks which are not inside closing methods, but the code that is failing does not have such code.

Community
  • 1
  • 1
ryan2johnson9
  • 724
  • 6
  • 21

1 Answers1

1

The errors I got were not helpful but I found the problem.

Rails4 now requires that scopes are defined using procs or lambdas. see this documentation

Rails 4.0 requires that scopes use a callable object such as a Proc or lambda:

scope :active, where(active: true)

becomes

scope :active, -> { where active: true }

By changing all of my model scopes to use lambdas, the issue was solved and I can query the db again.

It seems that even one outdated scope ruins all db calls.

ryan2johnson9
  • 724
  • 6
  • 21