Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于我的网站,一旦用户选择了他/她的性别并保存了个人资料,我希望将性别属性冻结。这样恶意用户就无法返回并更改他/她的性别。我怎样才能做到这一点?现在用户模型attr_accessor包括:gender
attr_accessor
:gender
您可以像这样指定只读属性:
attr_readonly :gender
这将允许最初保存性别属性,但永远不会更新。