Ruby is already using the class name of my model

后端 未结 3 1819
攒了一身酷
攒了一身酷 2021-01-07 01:46

I\'m making a forum application with various levels of authorization, one of which is a Monitor. I am doing this by extending my User class, and I plan on fine tuning this

3条回答
  •  一个人的身影
    2021-01-07 02:04

    FYI, I just found a neat trick (errr, hack) to get around this which may work.

    I work on a large legacy application which, unfortunately, has a "Fixture" model which is quite important and which is used everywhere. When running tests, it's impossible to create a Fixture instance because of the Fixture class used by ActiveRecord when running tests. So I did the following:

    FixtureModel = Fixture.dup
    

    This freezes my class in place so that I can refer to it later (but just in my tests!) without being extended by the ActiveRecord Fixture class (which is not namespaced)

提交回复
热议问题