I create a RoR application.

But when I add new model called Queue and these appear these error:

ActionView::Template::Error (undefined method `arel_table' for Queue:Class):

It's Queue a reserved word for rails or ruby? What's wrong?

Thanks in advance.

有帮助吗?

解决方案

It is not a reserved word, but there already is a class with that name: http://www.ruby-doc.org/stdlib-2.0/libdoc/thread/rdoc/Queue.html. This means that when you call Queue, rails constant_missing method is not triggered, and your new class is not being loaded.

There are two solutions. First one is obvious, rename your class. The second one is to remove previous definition:

Object.send(:remove_const, :Queue)

in one of your initailizers. Note however that this might be misleading later if you decide to use the original Queue, and is absolutely off the table if you are currently using it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top