Rails: Is that possible to define named scope in a module?

后端 未结 3 1563
迷失自我
迷失自我 2020-12-14 01:34

Say there are 3 models: A, B, and C. Each of these models has the x attribute.

Is that possible to define a named scope in a module and include this mod

3条回答
  •  悲哀的现实
    2020-12-14 01:49

    As for Rails 4.x you can use gem scopes_rails

    It can generate scopes file and include it to your model.

    Also, it can automatically generate scopes for state_machines states.

提交回复
热议问题