tiny_dyno 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e189c01a3f68cd0b380b35eaea4a0edbfa52578c
4
+ data.tar.gz: 5be36bd2c1f97a3a7a7edf4be34581b3b3de09cd
5
+ SHA512:
6
+ metadata.gz: 25161a1faf09b898f40894dce7234accc7aa1d35b2d072fa17b0e5d09fbc8c41e15629d454ea6743fb079b08b5925f902acc4b90de8ccf1b440ac42a7dda5bd7
7
+ data.tar.gz: bc56b228fc8ed10ea00eecef27d6536e77dbe323d994bb3387a99ef80f0c2450a015ff1a9bda363d5bc97adbdcba3220c166ff4f63bc07b0d0f0658a749c8d02
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/.simplecov ADDED
@@ -0,0 +1,2 @@
1
+ SimpleCov.start
2
+ SimpleCov.minimum_coverage 85
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tiny_dyno.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(lib spec) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec spec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE ADDED
@@ -0,0 +1,41 @@
1
+ Copyright (c) 2015 Tobias Gerschner, RataWorks
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ Copyright (c) 2009-2013 Durran Jordan
23
+
24
+ Permission is hereby granted, free of charge, to any person obtaining
25
+ a copy of this software and associated documentation files (the
26
+ "Software"), to deal in the Software without restriction, including
27
+ without limitation the rights to use, copy, modify, merge, publish,
28
+ distribute, sublicense, and/or sell copies of the Software, and to
29
+ permit persons to whom the Software is furnished to do so, subject to
30
+ the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be
33
+ included in all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ Minimalist ODM for commonly used operations with dynamodb.
2
+ ==========================================================
3
+
4
+ This is not a complete ODM for DynamoDB!
5
+ Check https://gitter.im/aws/aws-sdk-ruby or http://ruby.awsblog.com/ for that instead, rumour has it one might be appearing soon.
6
+
7
+ This work is heavily influenced in layout by the awesome mongoid gem, which I have used for years. Since I shouldn't be writing a full ODM I have borrowed as much as needed, especially to implement ActiveSupport::Concern way of module dependency resolution.
8
+ I also shied away from reinventing perfectly valid methods if they were in Mongoid. So, if code looks familiar to you, it probably is.
9
+
10
+ So, thanks goes to Durran Jordan @ mongoid/mongoid.
11
+
12
+ Beyond that, TinyDyno is a <working>, no frills abstraction to work with DynamoDB on EC2 within ruby apps.
13
+
14
+ If you're new to DynamoDB, it is highly recommended to read the following:
15
+
16
+ [GettingStartedDynamoDB](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStartedDynamoDB.html)
17
+
18
+ [GuidelinesForTables](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GuidelinesForTables.html)
19
+
20
+ Supported Operations
21
+ --------------------
22
+
23
+ create_table
24
+ ------------
25
+
26
+ Indexes in dynamo are created at table creation time.
27
+
28
+ either Model.create_table
29
+
30
+ rake tiny_dyno:create_tables
31
+
32
+ delete_table
33
+ ------------
34
+
35
+ Model.delete_table
36
+
37
+ put_item
38
+ --------
39
+
40
+ http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#put_item-instance_method
41
+ Invoked upon create/create!
42
+
43
+ supported keys;
44
+
45
+ * table_name
46
+ * item
47
+
48
+ update_item
49
+ -----------
50
+
51
+ http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html#update_item-instance_method
52
+ Invoked upon save on existing objects.
53
+
54
+ supported_keys;
55
+
56
+ * table_name
57
+ * key
58
+ * attribute_updates
59
+
60
+ delete_item
61
+ ------------
62
+
63
+ * hash_key
64
+
65
+ Installation
66
+ ============
67
+
68
+ Add this line to your application's Gemfile:
69
+
70
+ ```ruby
71
+ gem 'tiny_dyno'
72
+ ```
73
+
74
+ And then execute:
75
+
76
+ $ bundle
77
+
78
+ Or install it yourself as:
79
+
80
+ $ gem install tiny_dyno
81
+
82
+ ## Usage
83
+
84
+ ```
85
+
86
+ require 'tiny_dyno'
87
+ class Person
88
+ include TinyDyno::Document
89
+
90
+ hash_key :id, type: Integer
91
+
92
+ field :first_name, type: String
93
+ field :last_name, type: String
94
+ field :age, type: Integer
95
+
96
+ end
97
+
98
+ require 'fabrication'
99
+
100
+ Fabricator(:person) do
101
+ id { Faker::Number.number(10) }
102
+ first_name { Faker::Name.first_name }
103
+ last_name { Faker::Name.last_name }
104
+ age { Faker::Number.number(2) }
105
+ end
106
+
107
+ person = Fabricate(:person)
108
+
109
+ ```
110
+
111
+ ## Development
112
+
113
+
114
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
115
+
116
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
117
+
118
+ ## Contributing
119
+
120
+ Bug reports and pull requests are welcome on GitHub at https://github.com/RataWorks/tiny_dyno.
121
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tiny_dyno"
5
+
6
+ require 'pry'
7
+
8
+ Pry.start
data/bin/fastcheck ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tiny_dyno'
5
+ require 'faker'
6
+ require 'fabrication'
7
+
8
+
9
+ Dir.glob(File.join(ENV['PWD'], 'spec/models/*.rb')).each do |f|
10
+ p "loading #{ f }"
11
+ require f
12
+ end
13
+
14
+ Fabrication.configure do |config|
15
+ config.fabricator_path = 'spec/fabricators'
16
+ config.sequence_start = 10000
17
+ end
18
+
19
+ Fabrication.manager.load_definitions
20
+
21
+ require 'pry'
22
+
23
+ Aws.config[:endpoint] = 'http://172.17.42.1:8000'
24
+
25
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/tracer ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tiny_dyno"
5
+
6
+ class SmallPerson
7
+ include TinyDyno::Document
8
+
9
+ hash_key :some_random, type: String
10
+
11
+ field :first_name, type: String
12
+ field :age, type: Integer
13
+
14
+ end
15
+
16
+ require 'tracer'
17
+ Tracer.on
18
+ sm = SmallPerson.new(first_name: 'peter_parker')
19
+
data/ci/tests.sh ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -x
4
+
5
+ setup_dynamodb_local() {
6
+
7
+ dynamodb_tar_file="dynamodb_local_2015-04-27_1.0.tar.gz"
8
+ dynamodb_dir=$HOME/dynamodb_local
9
+
10
+ if ! test -f "$HOME/$dynamodb_tar_file"
11
+ then
12
+ wget --continue --directory-prefix=$HOME -- "http://dynamodb-local.s3-website-us-west-2.amazonaws.com/${dynamodb_tar_file}"
13
+ fi
14
+ mkdir -p "$dynamodb_dir"
15
+ tar -xf $HOME/$dynamodb_tar_file -C ${dynamodb_dir}
16
+
17
+ }
18
+
19
+ test "$SNAP_CI" == "true" && setup_dynamodb_local
20
+
21
+ export AWS_ACCESS_KEY_ID='foo'
22
+ export AWS_SECRET_ACCESS_KEY='bar'
23
+ export AWS_REGION="us-west-2"
24
+
25
+ export BUNDLE_PATH="${SNAP_CACHE_DIR}/bundle-cache/tiny_ddb"
26
+
27
+ export JRUBY_OPTS=" -Xcli.debug=true --debug "
28
+
29
+ bundle install --clean
30
+
31
+ #bundle exec rspec spec/dynamodb_unavailable/ ; unavail_exit_status=$?
32
+ #test "$unavail_exit_status" -eq 0 || exit $unavail_exit_status
33
+
34
+ pushd $dynamodb_dir
35
+ java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -inMemory & dynamodb_pid=$!
36
+ popd
37
+
38
+ sleep 10
39
+ curl -s http://127.0.0.1:8000 ; dynamodb_local=$?
40
+
41
+ if test "$dynamodb_local" -eq 0
42
+ then
43
+ echo "DynamoDB_Local is up, all tests should pass"
44
+ else
45
+ echo "DynamoDB_Local setup failed, persistence tests will fail" 1>&2
46
+ fi
47
+
48
+ bundle exec rspec spec/tiny_dyno ; avail_exit_status=$?
49
+
50
+ test "$SNAP_CI" == "true" && test -n "$dynamodb_pid" && kill -15 $dynamodb_pid
51
+
52
+ exit $avail_exit_status
@@ -0,0 +1,168 @@
1
+ en:
2
+ tiny_dyno:
3
+ errors:
4
+ messages:
5
+ blank_in_locale:
6
+ "can't be blank in %{location}"
7
+ callbacks:
8
+ message: "Calling %{method} on %{klass} resulted in a false return
9
+ from a callback."
10
+ summary: "If a before callback returns false when using Document.create!,
11
+ Document#save!, or Document#update_attributes! this error will get raised
12
+ since the document did not actually get saved."
13
+ resolution: "Double check all before callbacks to make sure they are
14
+ not unintentionally returning false."
15
+ document_not_destroyed:
16
+ message: "%{klass} with id %{id} was not destroyed."
17
+ summary: "When calling %{klass}#destroy! and a callback halts the destroy
18
+ callback chain by returning a false value, the deletion will not
19
+ actually occur."
20
+ resolution: "Check the before/after destroy callbacks to ensure that the
21
+ return values are truthy for the chain to continue."
22
+ document_not_found:
23
+ message: "Document(s) not found for class %{klass} with id(s) %{missing}."
24
+ summary: "When calling %{klass}.find with an id or array of ids, each
25
+ parameter must match a document in the database or this error will be
26
+ raised. The search was for the id(s): %{searched} (%{total} total)
27
+ and the following ids were not found: %{missing}."
28
+ resolution: "Search for an id that is in the database or set
29
+ the Mongoid.raise_not_found_error configuration option to false,
30
+ which will cause a nil to be returned instead of raising this error when
31
+ searching for a single id, or only the matched documents when searching
32
+ for multiples."
33
+ invalid_field:
34
+ message: "Defining a field named '%{name}' is not allowed."
35
+ summary: "Defining this field would override the method '%{name}',
36
+ which would cause issues with expectations around the original
37
+ method and cause extremely hard to debug issues. The original
38
+ method was defined in:\n
39
+ \_\_Object: %{origin}\n
40
+ \_\_File: %{file}\n
41
+ \_\_Line: %{line}"
42
+ resolution: "Use Mongoid.destructive_fields to see what names are not
43
+ allowed, and don't use these names. These include names that also
44
+ conflict with core Ruby methods on Object, Module, Enumerable, or
45
+ included gems that inject methods into these or Mongoid internals."
46
+ hash_keys_only:
47
+ message: "You can only search by defined hash_keys"
48
+ summary: 'Only searches which use a hash key are permitted.
49
+ Queries that do not use a hash key are highly inefficient and not
50
+ advisable in production use.'
51
+ resolution: 'Document and analyse your access patterns and amend your document
52
+ model accordingly.'
53
+ invalid_field_option:
54
+ message: "Invalid option :%{option} provided for field :%{name}."
55
+ summary: "Mongoid requires that you only provide valid options on each
56
+ field definition in order to prevent unexpected behaviour later on."
57
+ resolution: "When defining the field :%{name} on '%{klass}', please provide
58
+ valid options for the field. These are currently: %{valid}. If you
59
+ meant to define a custom field option, please do so first like so:\n\n
60
+ \_\_Mongoid::Fields.option :%{option} do |model, field, value|\n
61
+ \_\_\_\_# Your logic here...\n
62
+ \_\_end\n
63
+ \_\_class %{klass}\n
64
+ \_\_\_\_include Mongoid::Document\n
65
+ \_\_\_\_field :%{name}, %{option}: true\n
66
+ \_\_end\n\n"
67
+ invalid_index:
68
+ message: "Invalid index specification on %{klass}: %{spec}, %{options}"
69
+ summary: "Indexes in Mongoid are defined as a hash of field name and
70
+ direction/2d pairs, with a hash for any additional options."
71
+ resolution: "Ensure that the index conforms to the correct syntax and
72
+ has the correct options.\n\n
73
+ Valid options are:\n
74
+ \_\_background: true|false\n
75
+ \_\_database: 'database_name'\n
76
+ \_\_drop_dups: true|false\n
77
+ \_\_name: 'index_name'\n
78
+ \_\_sparse: true|false\n
79
+ \_\_unique: true|false\n
80
+ \_\_min: 1\n
81
+ \_\_max: 1\n
82
+ \_\_bits: 26\n
83
+ \_\_bucket_size : 1\n
84
+ \_\_weights: { content: 1, title: 2 }\n
85
+ \_\_expire_after_seconds: number_of_seconds\n
86
+ Valid types are: 1, -1, '2d', '2dsphere', 'geoHaystack', 'text', 'hashed'\n\n
87
+ Example:\n
88
+ \_\_class Band\n
89
+ \_\_\_\_include Mongoid::Document\n
90
+ \_\_\_\_index({ name: 1, label: -1 }, { sparse: true })\n
91
+ \_\_\_\_index({ location: '2d' }, { background: true })\n
92
+ \_\_end\n\n"
93
+ invalid_options:
94
+ message: "Invalid option :%{invalid} provided to relation :%{name}."
95
+ summary: "Mongoid checks the options that are passed to the relation
96
+ macros to ensure that no ill side effects occur by letting something
97
+ slip by."
98
+ resolution: "Valid options are: %{valid}, make sure these are the ones
99
+ you are using."
100
+ invalid_time:
101
+ message: "'%{value}' is not a valid Time."
102
+ summary: "Mongoid tries to serialize the values for Date, DateTime, and
103
+ Time into proper UTC times to store in the database. The provided
104
+ value could not be parsed."
105
+ resolution: "Make sure to pass parsable values to the field setter
106
+ for Date, DateTime, and Time objects. When this is a String it needs
107
+ to be valid for Time.parse. Other objects must be valid to pass to
108
+ Time.local."
109
+ invalid_value:
110
+ message: "Value of type %{value_class} cannot be written to a field of type %{field_class}"
111
+ summary: "Tried to set a value of type %{value_class} to a field of type %{field_class}"
112
+ resolution: "Verify if the value to be set correspond to field definition"
113
+ no_environment:
114
+ message: "Could not load the configuration since no environment
115
+ was defined."
116
+ summary: "Mongoid attempted to find the appropriate environment
117
+ but no Rails.env, Sinatra::Base.environment, RACK_ENV, or
118
+ MONGOID_ENV could be found."
119
+ resolution: "Make sure some environment is set from the mentioned
120
+ options. Mongoid cannot load configuration from the yaml without
121
+ knowing which environment it is in, and we have considered
122
+ defaulting to development an undesireable side effect of this not
123
+ being defined."
124
+ readonly_attribute:
125
+ message: "Attempted to set the readonly attribute '%{name}' with
126
+ the value: %{value}."
127
+ summary: "Attributes flagged as readonly via Model.attr_readonly
128
+ can only have values set when the document is a new record."
129
+ resolution: "Don't define '%{name}' as readonly, or do not attempt
130
+ to update its value after the document is persisted."
131
+ readonly_document:
132
+ message: "Attempted to persist the readonly document '%{klass}'."
133
+ summary: "Documents loaded from the database using #only
134
+ cannot be persisted."
135
+ resolution: "Don't attempt to persist documents that are flagged as
136
+ readonly."
137
+ taken:
138
+ "is already taken"
139
+ unknown_attribute:
140
+ message: "Attempted to set a value for '%{name}' which you did not
141
+ define on the model %{klass}."
142
+ summary: "Setting Attributes without first specifying is not permitted.
143
+ This is also triggered by passing the attribute to any method that
144
+ accepts an attributes hash, and is raised instead of getting a NoMethodError."
145
+ resolution: "Review your access pattern and your document structure,
146
+ and either add a field, store the attribute in a nested structure or
147
+ add a range key, if you need to use this attribute to retrieve this
148
+ type of document."
149
+ unsaved_document:
150
+ message: "Attempted to save %{document} before the parent %{base}."
151
+ summary: "You cannot call create or create! through the
152
+ relation (%{document}) who's parent (%{base}) is
153
+ not already saved. This would case the database to be out of sync
154
+ since the child could potentially reference a nonexistant parent."
155
+ resolution: "Make sure to only use create or create! when the parent
156
+ document %{base} is persisted."
157
+ validations:
158
+ message: "Validation of %{document} failed."
159
+ summary: "The following errors were found: %{errors}"
160
+ resolution: "Try persisting the document with valid data or remove
161
+ the validations."
162
+ delete_restriction:
163
+ message: "Cannot delete %{document} because of dependent '%{relation}'."
164
+ summary: "When defining '%{relation}' with a :dependent => :restrict,
165
+ Mongoid will raise an error when attempting to delete the
166
+ %{document} when the child '%{relation}' still has documents in it."
167
+ resolution: "Don't attempt to delete the parent %{document} when
168
+ it has children, or change the dependent option on the relation."