Mongo Mapper


attr_accessible allows you to specify a whitelist of keys that can be set when using mass-assignment. It can be called multiple times, each call adds to the already declared attributes. The opposite of attr_protected.

class User
  include MongoMapper::Document

  key :name, String
  key :email, String
  key :admin, Boolean

  attr_accessible :name, :email

user ={
  :name => 'John',
  :email => '',
  :admin => true
}) # 'John' # ''
user.admin # nil
Fork me on GitHub