Handling namespace models (classes) in namespace

后端 未结 1 343
孤街浪徒
孤街浪徒 2020-12-13 13:44

I am using Ruby on Rails 3 and I would like to handle models (classes) namespaces within namespaces. That is, if I have a namespace named NS1 and a \"sub-namespace\

相关标签:
1条回答
  • 2020-12-13 14:38

    The

    models/ns1/articles.rb

    is basically setting the table name prefix for all the model classes under that namespace. Thats its use. It's more DRY'ish to do in there (in a single file), rather than setting the prefix in every model class under that namespace.

    I am not a big fan of using namespaces in my models. However you could refer to the following articles to gain a better understanding about using namespaces in modules.

    • Namespaced models and controllers

    Some alternatives to using namespaces in models

    • A simple alternative to namespaced models

    Hope this helps.

    0 讨论(0)
提交回复
热议问题