Postgres ActiveRecord将表大小限制为一行(Postgres ActiveRecord limit table size to one row)

编程入门 行业动态 更新时间:2024-10-21 15:33:18
Postgres ActiveRecord将表大小限制为一行(Postgres ActiveRecord limit table size to one row)

我正在使用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.

更多推荐

本文发布于:2023-07-16 12:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128587.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   ActiveRecord   Postgres   limit   row

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!