我正在使用Sinatra和Postgres创建一个自定义CMS,并启用了sinatra-activerecord 。 我正在创建一个名为SiteInfo的模型,它将存储诸如about_description , about_photo , tagline等信息。在迁移中是否有办法创建SiteInfo表以指定只能有一行? 管理员或用户无法创建额外的界面,我只是想知道。
I am creating a custom CMS using Sinatra and Postgres with sinatra-activerecord enabled. I am creating a model called SiteInfo which will store information such as the about_description, about_photo, tagline, etc. Is there a way within the migration to create that SiteInfo table to specify that there can only be one row? There's no way through the interface for the admin or user to create an additional one, I'm just wondering.
最满意答案
回答你的问题:不,你不能,也没有必要。
无论如何,你会想要像SiteInfo.first加载你的信息。
To answer your question: No, you can't, and there is no need for.
You'll want to do something like SiteInfo.first to load your information anyway.
更多推荐
发布评论