Skip to content

Instantly share code, notes, and snippets.

@benedikt
Created March 5, 2012 08:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save benedikt/1977438 to your computer and use it in GitHub Desktop.
Save benedikt/1977438 to your computer and use it in GitHub Desktop.
Protect all fields against mass assignment in a mongoid document by default
module Mongoid
module MassAssignmentSecurity
extend ActiveSupport::Concern
included do
attr_accessible nil
end
end
module Document
include MassAssignmentSecurity
end
end
@nickpoorman
Copy link

Sorry for the noobish question but where did you place this in your rails project to get it to load?

@benedikt
Copy link
Author

I dropped it into config/initializers :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment