Sha256: 2f0c6b71cccd1596a86517a15a6e4f9e662f2a00cfaf01bb12c152b799aa1c50

Contents?: true

Size: 557 Bytes

Versions: 34

Compression:

Stored size: 557 Bytes

Contents

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'mongo_mapper'

MongoMapper.database = 'testing'

class User
  include MongoMapper::Document
  key :email, String
  key :admin, Boolean, :default => false

  # Only accessible or protected can be used, they cannot be used together
  attr_accessible :email
end

# only accessible are set on new/create/etc.
user = User.create(:email => 'IDontLowerCaseThings@gmail.com', :admin => true)
puts user.admin # false

# can be set using accessor
user.admin = true
user.save
puts user.admin # true

Version data entries

34 entries across 34 versions & 7 rubygems

Version Path
mongo_mapper-0.17.0 examples/attr_accessible.rb
mongo_mapper-0.16.0 examples/attr_accessible.rb
mongo_mapper-0.15.6 examples/attr_accessible.rb
mongo_mapper-0.15.5 examples/attr_accessible.rb
mongo_mapper-0.15.4 examples/attr_accessible.rb
mongo_mapper-0.15.3 examples/attr_accessible.rb
mongo_mapper-0.15.2 examples/attr_accessible.rb
mongo_mapper-0.15.1 examples/attr_accessible.rb
mongo_mapper-0.15.0 examples/attr_accessible.rb
mongo_mapper-0.14.0 examples/attr_accessible.rb
mongo_mapper-0.14.0.rc1 examples/attr_accessible.rb
mongo_mapper-0.13.1 examples/attr_accessible.rb
mongo_mapper-0.13.0 examples/attr_accessible.rb
mongo_mapper-0.13.0.beta2 examples/attr_accessible.rb
mongo_mapper-0.13.0.beta1 examples/attr_accessible.rb
mongo_mapper-0.12.0 examples/attr_accessible.rb
lookout-mongo_mapper-0.11.3 examples/attr_accessible.rb
mongo_mapper-0.11.2 examples/attr_accessible.rb
jamieorc-mongo_mapper-0.11.1.1 examples/attr_accessible.rb
mongo_mapper-0.11.1 examples/attr_accessible.rb