铁轨亲子会
因此,我正在创建一个数据库架构来表示文章库。然而,每篇文章都可以有多种翻译。因此,有一篇基础文章,其中包含共享信息以及该文章的翻译。我目前有一个文章表/类和一个翻译表/类。每篇文章都有_很多翻译等等。但我的问题是,是否有一种好的方法来委托方法并使用该系统查找文章。
我应该在文章类上创建自己的工厂方法来检索正确的翻译子项吗?我是否应该在翻译中添加委托人,以便我可以联系父级并获取有关该文章的共享信息?
另一个大问题是named_scopes会去哪里。他们应该继续阅读文章还是翻译?我正在尝试想出最好的方法来抽象出一篇文章和它的翻译之间的差异,并且只有一堆文章。想法?
谢谢!
So I am creating a db schema that will represent a library of articles. Each article, however, can have many translations. So, There is a base article, which contains the shared info, and translations for that article. I currently have an article table/class and a translation table/class. Every article has_many translations and so on. My question though, is if there is a good way to delegate methods and find articles with this system.
Should I make my own factory methods on the article class to retrieve the correct translation child? Should I add delegators on the translation so that I can reach back into the parent and get shared info about the article?
Another big concern is where named_scopes would go. Should they go on the article or its translation? I am trying to think of the best way to abstract away the difference between an article and its translation and just have a bunch of articles. Thoughts?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为我会使用范围来获取基于语言的文章和翻译。就像文章模型中的那样:
I think that i would use a scope to get an article and translation based on a language. It would be like that in the article model :