I'm doing my first steps in Rails and in object-oriented programming.
There is something quite fudemental that I would like to understand: why do we need attr_accessible
within the model?
I have read that hackers can use mass-assignment in order to change database entries and therefore compremise security, and that's why sensitive fields need protection (using atribute_protected
in this case).
Is attr_accessible
the opposite of atribute_protected
? If so, why do we need to state which fields are accessible and which are not? aren't those fields accessible by defult? And what is attr_accessor
used for?
I noticed that if I don't make some fields acessible, my application doesn't run. Can I use attr_acessible for sensitive fields like :password_digest and :admin?
It would be amazing if someone could explain it to me.
All the best, TimmyOnRails