将整个应用程序共享的部分内容放在哪里? [英] Where to put partials shared by the whole application in Rails?
本文介绍了将整个应用程序共享的部分内容放在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在哪里可以放置多个模型共享的部分文件?
我有一个名为 crop.html.erb
的页面,该页面用于一种模型-照片
。
现在,我也想将其用于另一个称为 User
的模型。
Where would I go about placing partial files shared by more than one model?
I have a page called crop.html.erb
that is used for one model - Photo
.
Now I would like to use it for another model called User
as well.
I 可以复制并粘贴代码,但不是很干,所以我想将其移到部分代码中。
I could copy and paste the code but that's not very DRY, so I figured I would move it into a partial.
由于两个模型之间共享- 我将那部分放置在哪里?
Since it's shared between two models - where would I place that partial?
谢谢!
推荐答案
Rails约定是将共享的部分文件放在 / app / views / shared
中。
The Rails convention is to put shared partials in /app/views/shared
.
这篇关于将整个应用程序共享的部分内容放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文