Search code examples
ruby-on-railsmass-assignment

What is the opposite of attr_accessible in Rails?


What is the opposite of attr_accessible in Rails?

Instead of writting every single attribute I want to write just the ones I want to block.


Solution

  • attr_protected

    Mass-assignment to these attributes will simply be ignored, to assign to them you can use direct writer methods. This is meant to protect sensitive attributes from being overwritten by malicious users tampering with URLs or forms.