我如何设置“attr_accessible"以不允许访问使用 Ruby on Rails 的模型的任何字段? [英] How I can set 'attr_accessible' in order to NOT allow access to ANY of the fields FOR a model using Ruby on Rails?
本文介绍了我如何设置“attr_accessible"以不允许访问使用 Ruby on Rails 的模型的任何字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果在模型文件中我只有这个代码:
If in a model file I have just this code:
class Users < ActiveRecord::Base
end
这是什么意思?与模型相关的所有属性是否可访问?
what this means? All attributes related to the model are accessible or not?
我如何设置attr_accessible"以便不允许访问任何该模型的字段?
How I can set 'attr_accessible' in order to not allow access to any of the fields for that model?
推荐答案
只需设置:
class Users < ActiveRecord::Base
attr_accessible #none
end
就像 Pan Thomakos 所说的(attr_accessible 是可以批量获取的参数数组.因此,如果您不发送任何符号,则将无法访问任何参数.
Like Pan Thomakos said (attr_accessible is the array of parameters that can be mass-ret. So if you send in no symbols, then no parameters will be accessible.
这篇关于我如何设置“attr_accessible"以不允许访问使用 Ruby on Rails 的模型的任何字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文