swanandp/acts_as_list — pull request #60 by graemeworthy (2012-11-16 21:27:38+00:00)
Title: attr-accessible can be damaging, is not always necessary.

Problem:
---
changes in the attr accessable patch from fabn/attr-accessible-patch
cause a problem on any model which does not already have attr_accessible set
and as a result triggers the "Can't mass-assign protected attributes"

commit where problem was introduced:
--
md5: d8c24c026901071b22cac2201a80dd5608d268b0

Test for problem:
---
The example included here in a test shows that adding attr_accessible to a model that
does not currently have mass assignment protection enabled, triggers mass_assignment
protection.

Solution:
---
I understand that this patch was inteded as a workaround, so as to add 'position'
to the list of available mass assignable attributes of the model,

The problem that required the offending patch is addressable in another manner:
it is not necessary to use 'update_attributes!' to set one known attribute.
instead, i have altered this to use update_attribute, as it doesn't trigger mass_assignment protection.
update_attribute only updates one attribute at a time, therefore avoiding 'mass' assignment.

-
that being said, it may still be desirable to add 'position' (or it's configured alternate)
to the list of mass_assignable attributes, but only if there is already such a list,

this patch performs a check to see if here is already a whitelist, and if so, adds itself to it.