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.
Rails 中的 attr_accessible 的对立面是什么?
我不想写每一个属性,我只想写我想要阻止的那些。
attr_protected
对这些属性的批量分配将被忽略,要分配给它们,您可以使用直接编写器方法。这是为了保护敏感属性不被篡改 URL 或表单的恶意用户覆盖。
它的 attr_protected,信息可以在这里找到...
http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html#method-i-attr_protected