将列添加到表后无法更新旧条目 Rails 3.1

发布于 2024-12-21 08:28:57 字数 136 浏览 2 评论 0原文

我有一个 Rails 应用程序,它已经与一些用户一起运行,我无法删除这些用户。

现在我已经在用户表中添加了几列(如姓氏、昵称)。

问题是,尽管新注册可以更改个人资料信息,但现有注册无法更改它们。

有什么帮助吗?

I have a rails app which is already running with some users, users that I cannot delete.

Now I have added a couple of columns to the user table(like last name, nickname).

The problem is that although new sign ups can change there profile information the existing ones cannot change them.

Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瀟灑尐姊 2024-12-28 08:28:57

那么,用户无法更新他们的任何信息吗?或者字段没有显示?

如果字段没有显示,请转到:

app/views/users/edit.html.erb

并查看表单的来源,您很可能需要在那里或现在添加字段

app/views/users/_form.html.erb

,如果用户无法编辑那里的信息,您要么需要创建机制来执行此操作(users#edit 和 users#update)或在迁移中自行更新记录。如果你不能做到这两件事,那就是一个设计缺陷:)

So, users are not able to update any of their information? Or the fields are not showing up?

If the fields are not showing up, go to:

app/views/users/edit.html.erb

And look where the form is coming from, you will most likely need to add the fields there or in

app/views/users/_form.html.erb

Now, if the users cannot edit there information, you either need to create the mechanism to do so (users#edit and users#update) or update the records yourself in the migration. If you can't do either of those things, it's a design flaw :)

人心善变 2024-12-28 08:28:57

我犯了一个愚蠢的错误,因为它没有更新配置文件中的条目。

我添加了新的列,其中一些在注册时是强制性的,但在更新个人资料时不是强制性的(例如:- 出生日期),因为我们认为没有人愿意更改其出生日期:)

因此,当现有用户我们正在尝试更新他们的个人资料,但由于我们应用的验证,出生日期字段在后端失败。

通过检查控制台弄清楚了。

I did a stupid mistake because of which it was not updating the entries in the profile.

I added new columns few of which were mandatory at the time of signup but were not mandatory when updating the profile (eg:- Date of Birth) as we thought no one would like to change their date of birth :)

So when the existing user were trying to update their profile the date of birth field was getting failed at the backend because of the validation which we had applied.

Figured it out by checking the console.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文