我有一个关于attr_accessible
在 Rails 中使用的问题。
我有时想设置guard_protected_attributes
为false
以绕过批量分配保护。我想知道为什么以下行不起作用(它会产生“无法字符串化键”错误):
@user.attributes=({ :name => "James Bond", :admin => true }, false)
...但这确实:
@user.send(:attributes=, { :name => "James Bond", :admin => true }, false)
有人知道原因吗?