默認情況下,rails 3.2
在config/environments/development.rb中設置active_record.mass_assignment_sanitizer = :strict
。 (見軌道廣播節目http://railscasts.com/episodes/318-upgrading-to-rails-3-2)。那就是:爲什麼在rails 3.2中'active_record.mass_assignment_sanitizer =:strict'?
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
這使得開發和力mass assignment
容易出錯列出每一個屬性爲attr_accessible
。默認情況下,在rails 3.2
(還沒有檢查它是否爲rails 4)時做這件事的理由是什麼?
查看此答案的第二個鏈接:http://stackoverflow.com/a/10050835/1128103 – Baldrick