只有一个用户的应用程序的 Rails 最佳实践?
我正在为一位客户建立一个网站,该客户希望能够对其网站上的内容进行编辑。因此,我需要一种方法来允许客户登录网站以进行更改。
我最初的想法是制作一个身份验证系统,该系统依赖于数据库中的用户表,该表最多只能有一个用户。然而,只为一个结果创建一个数据库表似乎有点矫枉过正,所以我想知道是否有任何其他方法或最佳实践可供任何人指出来构建只有一个用户的网站。
I am building a website for a client that wants to be able to make edits to things on their website. As such I need a way to allow the client to login to the site to make their changes.
My initial thought was to make an authentication system that relies on a User table in the database that is capped at one and only one user. It seems sort of overkill however to make a database table for just one result, so I was wondering if there were any other approaches or best practices that anyone could point to for building a site with just one user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想要数据库模型,您可以简单地使用从文件(加密)接收的静态密码进行身份验证。
然而,使用像 Devise 这样的 gem 设置身份验证大约需要 10 分钟的工作。为了更安全(即使在单用户应用程序中也可能是一个问题),您可以设置它并且没问题:)
You could simply authenticate with a static password that is received from a file(encrypted), if you do not want a db model for that.
However, setting authentication with a gem like Devise is like 10 minutes of work. In order to be more secure(it can be a matter even in single user apps), you can set it up and be fine :)
我强烈建议您设置身份验证。正如 SpyrosP 所说,当您使用 Devise 时,它不会花费很长时间。
I would highly recommend you set up authentication. As SpyrosP said it does not take long when you use Devise.