Skip to content


Subversion checkout URL

You can clone with
Download ZIP


can't have a column called scope #8850

robmathews opened this Issue · 11 comments

6 participants


Create a model Foo with a column called scope. Then try to find all the matching Foo by scope, like so:


You get this traceback:

[7] pry(main)> Foo.where(:scope=>1).first
SystemStackError: stack level too deep

This on rails 3.2.10 and ruby 1.9.3p327

I can provide more details if you want, but it seems pretty straightforward ...


scope is a reserved word, therefore using it as a column name will not work.


Well, scope isn't on this list as a reserved word for columns. It says to avoid using it as an association name, that is all. And I can't find any more up to date list of reserved words.


Yes, it'd be impossible to keep the list up-to-date.


Impossible to keep the list of up to date? Really?


That seems like a potential usability nightmare, if that's actually true. I don't have much stake in the original issue here, but just keeping a textual list somewhere seems pretty reasonable.

On the other hand, I admit that in a few years of rails work, I've never been bit by this....

If not a list somewhere, how should new rails devs know what column names to avoid? Has to be something you've got some input on from personal experience, @steveklabnik.


@robmathews Are you sure you can reproduce the situation with a vanilla app?
I tried in both master and newest 3.2 but Foo.where(:scope=>1).first just works fine for me.
I guess one of the gems you're bundling is actually causing your "stack level too deep".


AR models inherit from AR::Base, inherited methods are not reserved words, we are talking standard OOP.


Yes, because in AR a column definition triggers the definition of a method with the same name.

That's why you can have a blank User class and still be able to write There, name is a method that has been defined on the fly.

So all ends in the same place, you need to define class interfaces that play well with the methods they inherit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.