我正在为我的个人网站制作投资组合部分。每个投资组合项目都有很多,看起来像这样:
<li>
<h3>Core Product</h3>
<ul>
<li>Snip</li>
<li>2011 to 2012</li>
</ul>
<%= link_to "http://sniphq.com/demo" %>
<p>
Snip is a company I started in January 2011.
I did all the programming, design, usability testing, sales, marketing—everything.
The overall idea is to allow hairstylists to spend more time on hair and less time on everything else.
</p>
</li>
我不喜欢这里的数据如何与数据的显示方式紧密结合。如果我可以这样做,我会很整洁:
snip:
client_name: Snip
project_name: Core Product
period: 2011 to 2012
link: http://sniphq.com/demo
description: Snip is a company I...
然后在我看来,我可以迭代这些项目。我意识到我可以为项目组合项创建一个数据库表,但对于我来说,作为一个内容编写者来说,维护起来会更难,而且作为程序员也比我需要它更复杂。
实现此类功能的最佳/最简单方法是什么?
答案 0 :(得分:1)
有一个名为StaticModel的gem,您可以在YAML文件中定义数据,它将具有ActiveRecord :: Base类的某些属性。请在此处查看:http://code.quirkey.com/static_model/