mongoid 2.8.1 → 3.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (351) hide show
  1. data/CHANGELOG.md +802 -58
  2. data/LICENSE +1 -1
  3. data/README.md +10 -11
  4. data/Rakefile +2 -8
  5. data/lib/config/locales/en.yml +441 -51
  6. data/lib/mongoid.rb +24 -39
  7. data/lib/mongoid/atomic.rb +16 -33
  8. data/lib/mongoid/atomic/modifiers.rb +2 -2
  9. data/lib/mongoid/atomic/paths/embedded.rb +4 -5
  10. data/lib/mongoid/atomic/paths/embedded/many.rb +6 -6
  11. data/lib/mongoid/atomic/paths/embedded/one.rb +5 -5
  12. data/lib/mongoid/atomic/paths/root.rb +4 -5
  13. data/lib/mongoid/attributes.rb +95 -32
  14. data/lib/mongoid/attributes/processing.rb +14 -10
  15. data/lib/mongoid/attributes/readonly.rb +56 -0
  16. data/lib/mongoid/callbacks.rb +90 -27
  17. data/lib/mongoid/collections/retry.rb +2 -3
  18. data/lib/mongoid/components.rb +11 -23
  19. data/lib/mongoid/config.rb +87 -233
  20. data/lib/mongoid/config/environment.rb +5 -6
  21. data/lib/mongoid/config/inflections.rb +6 -0
  22. data/lib/mongoid/config/options.rb +1 -1
  23. data/lib/mongoid/config/validators.rb +3 -0
  24. data/lib/mongoid/config/validators/option.rb +25 -0
  25. data/lib/mongoid/config/validators/session.rb +140 -0
  26. data/lib/mongoid/contextual.rb +50 -0
  27. data/lib/mongoid/contextual/aggregable/memory.rb +98 -0
  28. data/lib/mongoid/contextual/aggregable/mongo.rb +181 -0
  29. data/lib/mongoid/contextual/atomic.rb +179 -0
  30. data/lib/mongoid/contextual/command.rb +43 -0
  31. data/lib/mongoid/contextual/find_and_modify.rb +66 -0
  32. data/lib/mongoid/contextual/map_reduce.rb +273 -0
  33. data/lib/mongoid/contextual/memory.rb +383 -0
  34. data/lib/mongoid/contextual/mongo.rb +543 -0
  35. data/lib/mongoid/copyable.rb +3 -34
  36. data/lib/mongoid/criteria.rb +436 -250
  37. data/lib/mongoid/criterion/inspection.rb +14 -8
  38. data/lib/mongoid/criterion/scoping.rb +114 -44
  39. data/lib/mongoid/dirty.rb +152 -67
  40. data/lib/mongoid/document.rb +69 -50
  41. data/lib/mongoid/errors.rb +22 -1
  42. data/lib/mongoid/errors/ambiguous_relationship.rb +51 -0
  43. data/lib/mongoid/errors/callback.rb +5 -6
  44. data/lib/mongoid/errors/delete_restriction.rb +29 -0
  45. data/lib/mongoid/errors/document_not_found.rb +98 -17
  46. data/lib/mongoid/errors/eager_load.rb +3 -6
  47. data/lib/mongoid/errors/invalid_collection.rb +3 -3
  48. data/lib/mongoid/errors/invalid_config_option.rb +27 -0
  49. data/lib/mongoid/errors/invalid_database.rb +3 -3
  50. data/lib/mongoid/errors/invalid_field.rb +54 -8
  51. data/lib/mongoid/errors/invalid_field_option.rb +35 -0
  52. data/lib/mongoid/errors/invalid_find.rb +3 -3
  53. data/lib/mongoid/errors/invalid_index.rb +28 -0
  54. data/lib/mongoid/errors/invalid_options.rb +4 -4
  55. data/lib/mongoid/errors/invalid_scope.rb +24 -0
  56. data/lib/mongoid/errors/invalid_set_polymorphic_relation.rb +38 -0
  57. data/lib/mongoid/errors/invalid_storage_options.rb +27 -0
  58. data/lib/mongoid/errors/invalid_time.rb +3 -6
  59. data/lib/mongoid/errors/inverse_not_found.rb +29 -0
  60. data/lib/mongoid/errors/mixed_relations.rb +4 -9
  61. data/lib/mongoid/errors/mixed_session_configuration.rb +28 -0
  62. data/lib/mongoid/errors/mongoid_error.rb +54 -3
  63. data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +28 -0
  64. data/lib/mongoid/errors/no_default_session.rb +23 -0
  65. data/lib/mongoid/errors/no_environment.rb +3 -3
  66. data/lib/mongoid/errors/no_map_reduce_output.rb +24 -0
  67. data/lib/mongoid/errors/no_parent.rb +24 -0
  68. data/lib/mongoid/errors/no_session_config.rb +22 -0
  69. data/lib/mongoid/errors/no_session_database.rb +27 -0
  70. data/lib/mongoid/errors/no_session_hosts.rb +27 -0
  71. data/lib/mongoid/errors/no_sessions_config.rb +20 -0
  72. data/lib/mongoid/errors/readonly_attribute.rb +25 -0
  73. data/lib/mongoid/errors/scope_overwrite.rb +4 -4
  74. data/lib/mongoid/errors/too_many_nested_attribute_records.rb +4 -4
  75. data/lib/mongoid/errors/unknown_attribute.rb +25 -0
  76. data/lib/mongoid/errors/unsaved_document.rb +4 -8
  77. data/lib/mongoid/errors/unsupported_javascript.rb +27 -0
  78. data/lib/mongoid/errors/unsupported_version.rb +4 -4
  79. data/lib/mongoid/errors/validations.rb +7 -6
  80. data/lib/mongoid/errors/versioning_not_on_root.rb +23 -0
  81. data/lib/mongoid/extensions.rb +28 -76
  82. data/lib/mongoid/extensions/array.rb +127 -0
  83. data/lib/mongoid/extensions/big_decimal.rb +42 -0
  84. data/lib/mongoid/extensions/boolean.rb +24 -0
  85. data/lib/mongoid/extensions/date.rb +70 -0
  86. data/lib/mongoid/extensions/date_time.rb +68 -0
  87. data/lib/mongoid/extensions/false_class.rb +26 -0
  88. data/lib/mongoid/extensions/float.rb +44 -0
  89. data/lib/mongoid/extensions/hash.rb +91 -0
  90. data/lib/mongoid/extensions/integer.rb +54 -0
  91. data/lib/mongoid/extensions/module.rb +28 -0
  92. data/lib/mongoid/extensions/nil_class.rb +21 -0
  93. data/lib/mongoid/extensions/object.rb +188 -0
  94. data/lib/mongoid/extensions/object_id.rb +53 -0
  95. data/lib/mongoid/extensions/range.rb +55 -0
  96. data/lib/mongoid/extensions/regexp.rb +27 -0
  97. data/lib/mongoid/extensions/set.rb +55 -0
  98. data/lib/mongoid/extensions/string.rb +155 -0
  99. data/lib/mongoid/extensions/symbol.rb +54 -0
  100. data/lib/mongoid/extensions/time.rb +78 -0
  101. data/lib/mongoid/extensions/time_with_zone.rb +55 -0
  102. data/lib/mongoid/extensions/true_class.rb +26 -0
  103. data/lib/mongoid/factory.rb +1 -1
  104. data/lib/mongoid/fields.rb +129 -194
  105. data/lib/mongoid/fields/foreign_key.rb +134 -0
  106. data/lib/mongoid/fields/localized.rb +73 -0
  107. data/lib/mongoid/fields/standard.rb +268 -0
  108. data/lib/mongoid/fields/validators.rb +2 -0
  109. data/lib/mongoid/fields/validators/macro.rb +83 -0
  110. data/lib/mongoid/finders.rb +42 -43
  111. data/lib/mongoid/hierarchy.rb +25 -14
  112. data/lib/mongoid/identity_map.rb +31 -19
  113. data/lib/mongoid/indexes.rb +66 -15
  114. data/lib/mongoid/indexes/validators/options.rb +80 -0
  115. data/lib/mongoid/inspection.rb +1 -1
  116. data/lib/mongoid/javascript.rb +1 -1
  117. data/lib/mongoid/json.rb +2 -2
  118. data/lib/mongoid/loggable.rb +69 -0
  119. data/lib/mongoid/matchers.rb +1 -1
  120. data/lib/mongoid/matchers/all.rb +7 -8
  121. data/lib/mongoid/matchers/and.rb +3 -3
  122. data/lib/mongoid/matchers/default.rb +6 -4
  123. data/lib/mongoid/matchers/exists.rb +2 -2
  124. data/lib/mongoid/matchers/gt.rb +2 -2
  125. data/lib/mongoid/matchers/gte.rb +2 -2
  126. data/lib/mongoid/matchers/in.rb +3 -7
  127. data/lib/mongoid/matchers/lt.rb +2 -2
  128. data/lib/mongoid/matchers/lte.rb +2 -2
  129. data/lib/mongoid/matchers/ne.rb +2 -2
  130. data/lib/mongoid/matchers/nin.rb +2 -2
  131. data/lib/mongoid/matchers/or.rb +2 -2
  132. data/lib/mongoid/matchers/size.rb +2 -2
  133. data/lib/mongoid/matchers/strategies.rb +3 -3
  134. data/lib/mongoid/multi_parameter_attributes.rb +8 -10
  135. data/lib/mongoid/nested_attributes.rb +17 -9
  136. data/lib/mongoid/observer.rb +1 -2
  137. data/lib/mongoid/paranoia.rb +13 -18
  138. data/lib/mongoid/persistence.rb +43 -39
  139. data/lib/mongoid/persistence/atomic.rb +2 -2
  140. data/lib/mongoid/persistence/atomic/add_to_set.rb +5 -9
  141. data/lib/mongoid/persistence/atomic/bit.rb +5 -7
  142. data/lib/mongoid/persistence/atomic/inc.rb +5 -7
  143. data/lib/mongoid/persistence/atomic/operation.rb +45 -6
  144. data/lib/mongoid/persistence/atomic/pop.rb +5 -7
  145. data/lib/mongoid/persistence/atomic/pull.rb +5 -7
  146. data/lib/mongoid/persistence/atomic/pull_all.rb +5 -7
  147. data/lib/mongoid/persistence/atomic/push.rb +4 -10
  148. data/lib/mongoid/persistence/atomic/push_all.rb +4 -10
  149. data/lib/mongoid/persistence/atomic/rename.rb +6 -7
  150. data/lib/mongoid/persistence/atomic/sets.rb +5 -7
  151. data/lib/mongoid/persistence/atomic/unset.rb +4 -5
  152. data/lib/mongoid/persistence/deletion.rb +2 -2
  153. data/lib/mongoid/persistence/insertion.rb +10 -16
  154. data/lib/mongoid/persistence/modification.rb +5 -9
  155. data/lib/mongoid/persistence/operations.rb +6 -19
  156. data/lib/mongoid/persistence/operations/embedded/insert.rb +7 -6
  157. data/lib/mongoid/persistence/operations/embedded/remove.rb +5 -5
  158. data/lib/mongoid/persistence/operations/insert.rb +4 -4
  159. data/lib/mongoid/persistence/operations/remove.rb +4 -4
  160. data/lib/mongoid/persistence/operations/update.rb +5 -5
  161. data/lib/mongoid/railtie.rb +26 -11
  162. data/lib/mongoid/railties/database.rake +22 -108
  163. data/lib/mongoid/relations.rb +4 -6
  164. data/lib/mongoid/relations/accessors.rb +119 -19
  165. data/lib/mongoid/relations/auto_save.rb +59 -5
  166. data/lib/mongoid/relations/binding.rb +211 -2
  167. data/lib/mongoid/relations/bindings/embedded/in.rb +16 -22
  168. data/lib/mongoid/relations/bindings/embedded/many.rb +9 -50
  169. data/lib/mongoid/relations/bindings/embedded/one.rb +10 -16
  170. data/lib/mongoid/relations/bindings/referenced/in.rb +31 -57
  171. data/lib/mongoid/relations/bindings/referenced/many.rb +8 -20
  172. data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +15 -19
  173. data/lib/mongoid/relations/bindings/referenced/one.rb +10 -24
  174. data/lib/mongoid/relations/builder.rb +3 -3
  175. data/lib/mongoid/relations/builders.rb +19 -16
  176. data/lib/mongoid/relations/builders/embedded/in.rb +5 -5
  177. data/lib/mongoid/relations/builders/embedded/many.rb +12 -12
  178. data/lib/mongoid/relations/builders/embedded/one.rb +6 -6
  179. data/lib/mongoid/relations/builders/nested_attributes/many.rb +8 -8
  180. data/lib/mongoid/relations/builders/nested_attributes/one.rb +4 -4
  181. data/lib/mongoid/relations/builders/referenced/in.rb +4 -4
  182. data/lib/mongoid/relations/builders/referenced/many.rb +5 -5
  183. data/lib/mongoid/relations/builders/referenced/many_to_many.rb +7 -5
  184. data/lib/mongoid/relations/builders/referenced/one.rb +5 -5
  185. data/lib/mongoid/relations/cascading.rb +6 -4
  186. data/lib/mongoid/relations/cascading/delete.rb +3 -5
  187. data/lib/mongoid/relations/cascading/destroy.rb +3 -3
  188. data/lib/mongoid/relations/cascading/nullify.rb +3 -3
  189. data/lib/mongoid/relations/cascading/restrict.rb +37 -0
  190. data/lib/mongoid/relations/constraint.rb +4 -3
  191. data/lib/mongoid/relations/conversions.rb +5 -6
  192. data/lib/mongoid/relations/cyclic.rb +7 -7
  193. data/lib/mongoid/relations/embedded/batchable.rb +346 -0
  194. data/lib/mongoid/relations/embedded/in.rb +23 -12
  195. data/lib/mongoid/relations/embedded/many.rb +99 -161
  196. data/lib/mongoid/relations/embedded/one.rb +25 -14
  197. data/lib/mongoid/relations/macros.rb +105 -61
  198. data/lib/mongoid/relations/many.rb +93 -14
  199. data/lib/mongoid/relations/metadata.rb +200 -45
  200. data/lib/mongoid/relations/nested_builder.rb +3 -5
  201. data/lib/mongoid/relations/one.rb +2 -2
  202. data/lib/mongoid/relations/options.rb +2 -2
  203. data/lib/mongoid/relations/polymorphic.rb +9 -9
  204. data/lib/mongoid/relations/proxy.rb +60 -31
  205. data/lib/mongoid/relations/referenced/in.rb +40 -15
  206. data/lib/mongoid/relations/referenced/many.rb +117 -132
  207. data/lib/mongoid/relations/referenced/many_to_many.rb +101 -46
  208. data/lib/mongoid/relations/referenced/one.rb +34 -13
  209. data/lib/mongoid/relations/reflections.rb +3 -3
  210. data/lib/mongoid/relations/synchronization.rb +19 -23
  211. data/lib/mongoid/relations/targets/enumerable.rb +86 -57
  212. data/lib/mongoid/reloading.rb +12 -14
  213. data/lib/mongoid/scoping.rb +329 -0
  214. data/lib/mongoid/serialization.rb +8 -27
  215. data/lib/mongoid/sessions.rb +359 -0
  216. data/lib/mongoid/sessions/factory.rb +106 -0
  217. data/lib/mongoid/sessions/mongo_uri.rb +93 -0
  218. data/lib/mongoid/sessions/validators.rb +2 -0
  219. data/lib/mongoid/sessions/validators/storage.rb +49 -0
  220. data/lib/mongoid/sharding.rb +6 -6
  221. data/lib/mongoid/state.rb +6 -7
  222. data/lib/mongoid/threaded.rb +167 -59
  223. data/lib/mongoid/threaded/lifecycle.rb +21 -22
  224. data/lib/mongoid/threaded/sessions.rb +0 -0
  225. data/lib/mongoid/timestamps.rb +1 -1
  226. data/lib/mongoid/timestamps/created.rb +8 -4
  227. data/lib/mongoid/timestamps/timeless.rb +6 -4
  228. data/lib/mongoid/timestamps/updated.rb +3 -3
  229. data/lib/mongoid/unit_of_work.rb +61 -0
  230. data/lib/mongoid/validations.rb +27 -19
  231. data/lib/mongoid/validations/associated.rb +2 -2
  232. data/lib/mongoid/validations/format.rb +2 -2
  233. data/lib/mongoid/validations/presence.rb +31 -5
  234. data/lib/mongoid/validations/uniqueness.rb +9 -12
  235. data/lib/mongoid/version.rb +2 -2
  236. data/lib/mongoid/versioning.rb +25 -26
  237. data/lib/rack/mongoid/middleware/identity_map.rb +3 -3
  238. data/lib/rails/generators/mongoid/config/config_generator.rb +1 -1
  239. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +59 -19
  240. data/lib/rails/generators/mongoid/model/model_generator.rb +7 -7
  241. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +2 -2
  242. data/lib/rails/generators/mongoid/observer/observer_generator.rb +4 -4
  243. data/lib/rails/generators/mongoid_generator.rb +5 -5
  244. data/lib/rails/mongoid.rb +69 -25
  245. metadata +110 -137
  246. checksums.yaml +0 -7
  247. data/lib/config/locales/bg.yml +0 -61
  248. data/lib/config/locales/de.yml +0 -61
  249. data/lib/config/locales/en-GB.yml +0 -64
  250. data/lib/config/locales/es.yml +0 -59
  251. data/lib/config/locales/fr.yml +0 -62
  252. data/lib/config/locales/hi.yml +0 -53
  253. data/lib/config/locales/hu.yml +0 -64
  254. data/lib/config/locales/id.yml +0 -62
  255. data/lib/config/locales/it.yml +0 -59
  256. data/lib/config/locales/ja.yml +0 -57
  257. data/lib/config/locales/kr.yml +0 -54
  258. data/lib/config/locales/nl.yml +0 -61
  259. data/lib/config/locales/pl.yml +0 -59
  260. data/lib/config/locales/pt-BR.yml +0 -60
  261. data/lib/config/locales/pt.yml +0 -60
  262. data/lib/config/locales/ro.yml +0 -66
  263. data/lib/config/locales/ru.yml +0 -61
  264. data/lib/config/locales/sv.yml +0 -60
  265. data/lib/config/locales/vi.yml +0 -62
  266. data/lib/config/locales/zh-CN.yml +0 -53
  267. data/lib/mongoid/collection.rb +0 -157
  268. data/lib/mongoid/collections.rb +0 -120
  269. data/lib/mongoid/collections/master.rb +0 -45
  270. data/lib/mongoid/collections/operations.rb +0 -44
  271. data/lib/mongoid/config/database.rb +0 -181
  272. data/lib/mongoid/config/replset_database.rb +0 -80
  273. data/lib/mongoid/contexts.rb +0 -25
  274. data/lib/mongoid/contexts/enumerable.rb +0 -313
  275. data/lib/mongoid/contexts/enumerable/sort.rb +0 -43
  276. data/lib/mongoid/contexts/mongo.rb +0 -487
  277. data/lib/mongoid/criterion/builder.rb +0 -34
  278. data/lib/mongoid/criterion/complex.rb +0 -84
  279. data/lib/mongoid/criterion/creational.rb +0 -34
  280. data/lib/mongoid/criterion/exclusion.rb +0 -110
  281. data/lib/mongoid/criterion/inclusion.rb +0 -290
  282. data/lib/mongoid/criterion/optional.rb +0 -259
  283. data/lib/mongoid/criterion/selector.rb +0 -177
  284. data/lib/mongoid/cursor.rb +0 -88
  285. data/lib/mongoid/default_scope.rb +0 -36
  286. data/lib/mongoid/errors/invalid_type.rb +0 -25
  287. data/lib/mongoid/extensions/array/deep_copy.rb +0 -25
  288. data/lib/mongoid/extensions/array/deletion.rb +0 -29
  289. data/lib/mongoid/extensions/false_class/equality.rb +0 -26
  290. data/lib/mongoid/extensions/hash/criteria_helpers.rb +0 -47
  291. data/lib/mongoid/extensions/hash/deep_copy.rb +0 -25
  292. data/lib/mongoid/extensions/hash/scoping.rb +0 -25
  293. data/lib/mongoid/extensions/integer/checks.rb +0 -23
  294. data/lib/mongoid/extensions/nil/collectionization.rb +0 -23
  295. data/lib/mongoid/extensions/object/checks.rb +0 -29
  296. data/lib/mongoid/extensions/object/deep_copy.rb +0 -21
  297. data/lib/mongoid/extensions/object/reflections.rb +0 -48
  298. data/lib/mongoid/extensions/object/substitutable.rb +0 -15
  299. data/lib/mongoid/extensions/object/yoda.rb +0 -44
  300. data/lib/mongoid/extensions/object_id/conversions.rb +0 -60
  301. data/lib/mongoid/extensions/proc/scoping.rb +0 -25
  302. data/lib/mongoid/extensions/string/checks.rb +0 -36
  303. data/lib/mongoid/extensions/string/conversions.rb +0 -22
  304. data/lib/mongoid/extensions/string/inflections.rb +0 -118
  305. data/lib/mongoid/extensions/symbol/checks.rb +0 -23
  306. data/lib/mongoid/extensions/symbol/inflections.rb +0 -67
  307. data/lib/mongoid/extensions/true_class/equality.rb +0 -26
  308. data/lib/mongoid/extras.rb +0 -31
  309. data/lib/mongoid/fields/internal/array.rb +0 -77
  310. data/lib/mongoid/fields/internal/big_decimal.rb +0 -63
  311. data/lib/mongoid/fields/internal/bignum.rb +0 -10
  312. data/lib/mongoid/fields/internal/binary.rb +0 -11
  313. data/lib/mongoid/fields/internal/boolean.rb +0 -58
  314. data/lib/mongoid/fields/internal/date.rb +0 -51
  315. data/lib/mongoid/fields/internal/date_time.rb +0 -28
  316. data/lib/mongoid/fields/internal/false_class.rb +0 -10
  317. data/lib/mongoid/fields/internal/fixnum.rb +0 -10
  318. data/lib/mongoid/fields/internal/float.rb +0 -47
  319. data/lib/mongoid/fields/internal/foreign_keys/array.rb +0 -88
  320. data/lib/mongoid/fields/internal/foreign_keys/object.rb +0 -56
  321. data/lib/mongoid/fields/internal/hash.rb +0 -11
  322. data/lib/mongoid/fields/internal/integer.rb +0 -59
  323. data/lib/mongoid/fields/internal/localized.rb +0 -62
  324. data/lib/mongoid/fields/internal/nil_class.rb +0 -53
  325. data/lib/mongoid/fields/internal/object.rb +0 -11
  326. data/lib/mongoid/fields/internal/object_id.rb +0 -46
  327. data/lib/mongoid/fields/internal/range.rb +0 -61
  328. data/lib/mongoid/fields/internal/set.rb +0 -57
  329. data/lib/mongoid/fields/internal/string.rb +0 -42
  330. data/lib/mongoid/fields/internal/symbol.rb +0 -43
  331. data/lib/mongoid/fields/internal/time.rb +0 -23
  332. data/lib/mongoid/fields/internal/time_with_zone.rb +0 -23
  333. data/lib/mongoid/fields/internal/timekeeping.rb +0 -122
  334. data/lib/mongoid/fields/internal/true_class.rb +0 -10
  335. data/lib/mongoid/fields/mappings.rb +0 -42
  336. data/lib/mongoid/fields/serializable.rb +0 -270
  337. data/lib/mongoid/identity.rb +0 -92
  338. data/lib/mongoid/keys.rb +0 -144
  339. data/lib/mongoid/logger.rb +0 -45
  340. data/lib/mongoid/multi_database.rb +0 -36
  341. data/lib/mongoid/named_scope.rb +0 -166
  342. data/lib/mongoid/relations/embedded/atomic.rb +0 -89
  343. data/lib/mongoid/relations/embedded/atomic/operation.rb +0 -63
  344. data/lib/mongoid/relations/embedded/atomic/pull.rb +0 -65
  345. data/lib/mongoid/relations/embedded/atomic/push_all.rb +0 -59
  346. data/lib/mongoid/relations/embedded/atomic/set.rb +0 -61
  347. data/lib/mongoid/relations/embedded/atomic/unset.rb +0 -41
  348. data/lib/mongoid/relations/referenced/batch.rb +0 -73
  349. data/lib/mongoid/relations/referenced/batch/insert.rb +0 -57
  350. data/lib/mongoid/safety.rb +0 -105
  351. data/lib/mongoid/scope.rb +0 -31
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Durran Jordan
1
+ Copyright (c) 2009-2012 Durran Jordan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
- Overview
1
+ Mongoid [![Build Status](https://secure.travis-ci.org/mongoid/mongoid.png?branch=master&.png)](http://travis-ci.org/mongoid/mongoid)
2
2
  ========
3
3
 
4
- About Mongoid
5
- -------------
6
-
7
4
  Mongoid is an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.
8
5
 
9
6
  Project Tracking
@@ -15,11 +12,7 @@ Project Tracking
15
12
  Compatibility
16
13
  -------------
17
14
 
18
- Mongoid is tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE, Rubinius, and JRuby.
19
-
20
- <img src="https://secure.travis-ci.org/mongoid/mongoid.png?branch=master&.png"/>
21
-
22
- [Build History](http://travis-ci.org/mongoid/mongoid)
15
+ Mongoid is tested against MRI 1.9.2, 1.9.3, 2.0.0, and JRuby (1.9).
23
16
 
24
17
  Documentation
25
18
  -------------
@@ -30,12 +23,18 @@ Please see the new Mongoid website for up-to-date documentation:
30
23
  Donating
31
24
  --------
32
25
 
33
- * [Support Mongoid at Pledgie](http://www.pledgie.com/campaigns/7757)
26
+ [Support Mongoid at Pledgie](http://www.pledgie.com/campaigns/7757)
27
+
28
+ <a href='http://www.pledgie.com/campaigns/7757'>
29
+ <img alt='Click here to lend your support to: Mongoid and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/7757.png?skin_name=chrome' border='0'/>
30
+ </a>
31
+
32
+ [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=durran&url=http://github.com/mongoid&title=mongoid&language=&tags=github&category=software)
34
33
 
35
34
  License
36
35
  -------
37
36
 
38
- Copyright (c) 2009, 2010, 2011 Durran Jordan
37
+ Copyright (c) 2009-2012 Durran Jordan
39
38
 
40
39
  Permission is hereby granted, free of charge, to any person obtaining
41
40
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -2,7 +2,6 @@ require "bundler"
2
2
  Bundler.setup
3
3
 
4
4
  require "rake"
5
- require "rspec"
6
5
  require "rspec/core/rake_task"
7
6
 
8
7
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
@@ -23,12 +22,8 @@ task :release => :build do
23
22
  system "gem push mongoid-#{Mongoid::VERSION}.gem"
24
23
  end
25
24
 
26
- RSpec::Core::RakeTask.new("spec:unit") do |spec|
27
- spec.pattern = "spec/unit/**/*_spec.rb"
28
- end
29
-
30
- RSpec::Core::RakeTask.new("spec:functional") do |spec|
31
- spec.pattern = "spec/functional/**/*_spec.rb"
25
+ RSpec::Core::RakeTask.new("spec") do |spec|
26
+ spec.pattern = "spec/**/*_spec.rb"
32
27
  end
33
28
 
34
29
  RSpec::Core::RakeTask.new('spec:progress') do |spec|
@@ -36,5 +31,4 @@ RSpec::Core::RakeTask.new('spec:progress') do |spec|
36
31
  spec.pattern = "spec/**/*_spec.rb"
37
32
  end
38
33
 
39
- task :spec => [ "spec:functional", "spec:unit" ]
40
34
  task :default => :spec
@@ -1,64 +1,454 @@
1
1
  en:
2
2
  mongoid:
3
+ inspection:
4
+ criteria: "#<Mongoid::Criteria\n
5
+ \_\_selector: %{selector},\n
6
+ \_\_options: %{options},\n
7
+ \_\_class: %{klass},\n
8
+ \_\_embedded: %{embedded}>\n"
9
+ metadata: "#<Mongoid::Relations::Metadata\n
10
+ \_\_autobuild: %{autobuild},\n
11
+ \_\_class_name: %{class_name},\n
12
+ \_\_cyclic: %{cyclic},\n
13
+ \_\_dependent: %{dependent},\n
14
+ \_\_inverse_of: %{inverse_of},\n
15
+ \_\_key: %{key},\n
16
+ \_\_macro: %{macro},\n
17
+ \_\_name: %{name},\n
18
+ \_\_order: %{order},\n
19
+ \_\_polymorphic: %{polymorphic},\n
20
+ \_\_relation: %{relation},\n
21
+ \_\_setter: %{setter},\n
22
+ \_\_versioned: %{versioned}>\n"
3
23
  errors:
4
24
  messages:
5
25
  blank:
6
- can't be blank
7
- taken:
8
- is already taken
26
+ "can't be blank"
27
+ blank_in_locale:
28
+ "can't be blank in %{location}"
29
+ ambiguous_relationship:
30
+ message: "Ambiguous relations %{candidates} defined on %{klass}."
31
+ summary:
32
+ "When Mongoid attempts to set an inverse document of a relation
33
+ in memory, it needs to know which relation it belongs to. When
34
+ setting %{name}, Mongoid looked on the class %{inverse}
35
+ for a matching relation, but multiples were found that could
36
+ potentially match: %{candidates}."
37
+ resolution: "On the %{name} relation on %{inverse} you must add an
38
+ :inverse_of option to specify the exact relationship on %{klass}
39
+ that is the opposite of %{name}."
9
40
  callbacks:
10
- "Calling %{method} on %{klass} resulted in a false return from a callback."
41
+ message: "Calling %{method} on %{klass} resulted in a false return
42
+ from a callback."
43
+ summary: "If a before callback returns false when using Document.create!,
44
+ Document#save!, or Documnet#update_attributes! this error will get raised
45
+ since the document did not actually get saved."
46
+ resolution: "Double check all before callbacks to make sure they are
47
+ not unintentionally returning false."
48
+ calling_document_find_with_nil_is_invalid:
49
+ message: "Calling Document.find with nil is invalid."
50
+ summary: "Document.find expects the parameters to be 1 or more ids, and
51
+ will return a single document if 1 id is provided, otherwise an array
52
+ of documents if multiple ids are provided."
53
+ resolution: "Most likely this is caused by passing parameters directly
54
+ through to the find, and the parameter either is not present or the
55
+ key from which it is accessed is incorrect."
11
56
  document_not_found:
12
- Document not found for class %{klass} with id(s) %{identifiers}.
57
+ message: "Document(s) not found for class %{klass} with id(s) %{missing}."
58
+ summary: "When calling %{klass}.find with an id or array of ids, each
59
+ parameter must match a document in the database or this error will be
60
+ raised. The search was for the id(s): %{searched} (%{total} total)
61
+ and the following ids were not found: %{missing}."
62
+ resolution: "Search for an id that is in the database or set
63
+ the Mongoid.raise_not_found_error configuration option to false,
64
+ which will cause a nil to be returned instead of raising this error when
65
+ searching for a single id, or only the matched documents when searching
66
+ for multiples."
67
+ document_with_attributes_not_found:
68
+ message: "Document not found for class %{klass} with attributes %{attributes}."
69
+ summary: "When calling %{klass}.find_by with a hash of attributes, all
70
+ attributes provided must match a document in the database of this error
71
+ will be raised."
72
+ resolution: "Search for attributes that are in the database or set
73
+ the Mongoid.raise_not_found_error configuration option to false,
74
+ which will cause a nil to be returned instead of raising this error."
13
75
  eager_load:
14
- "Eager loading :%{name} is not supported due to it being a many-to-many
15
- or polymorphic belongs_to relation."
16
- invalid_database:
17
- "Database should be a Mongo::DB, not %{name}."
18
- invalid_time:
19
- "'%{value}' is not a valid Time."
20
- invalid_options:
21
- "Invalid option :%{invalid} provided to relation :%{name}. Valid options
22
- are: %{valid}."
23
- invalid_type:
24
- Field was defined as a(n) %{klass}, but received a %{other} with
25
- the value %{value}.
26
- unsupported_version:
27
- MongoDB %{version} not supported, please upgrade
28
- to %{mongo_version}.
29
- validations:
30
- Validation failed - %{errors}.
76
+ message: "Eager loading :%{name} is not supported since it is a
77
+ polymorphic belongs_to relation."
78
+ summary: "Mongoid cannot currently determine the classes it needs to
79
+ eager load when the relation is polymorphic. The parents reside in
80
+ different collections so a simple id lookup is not sufficient enough."
81
+ resolution: "Don't attempt to perform this action and have patience,
82
+ maybe this will be supported in the future."
31
83
  invalid_collection:
32
- Access to the collection for %{klass} is not allowed since it
33
- is an embedded document, please access a collection from
34
- the root document.
84
+ message: "Access to the collection for %{klass} is not allowed."
85
+ summary: "%{klass}.collection was called, and %{klass} is an embedded
86
+ document - it resides within the collection of the root document of
87
+ the hierarchy."
88
+ resolution: "For access to the collection that the embedded document is
89
+ in, use %{klass}#_root.collection, or do not attempt to persist an
90
+ embedded document without a parent set."
91
+ invalid_config_option:
92
+ message: "Invalid configuration option: %{name}."
93
+ summary: "A invalid configuration option was provided in your
94
+ mongoid.yml, or a typo is potentially present. The valid configuration
95
+ options are: %{options}."
96
+ resolution: "Remove the invalid option or fix the typo. If you were
97
+ expecting the option to be there, please consult the following page
98
+ with repect to Mongoid's configuration:\n\n
99
+ \_\_http://mongoid.org/docs/installation.html"
100
+ invalid_database:
101
+ message: "Database should be a Mongo::DB, not %{name}."
102
+ summary: "When setting a master database in the Mongoid configuration
103
+ it must be an actual instance of a Mongo::DB, and not just a name
104
+ of the database. This check is performed when calling
105
+ Mongoid.master = object."
106
+ resolution: "Make sure that when setting the configuration
107
+ programatically that you are passing an actual db instance."
35
108
  invalid_field:
36
- Defining a field named %{name} is not allowed. Do not define
37
- fields that conflict with Mongoid internal attributes or method
38
- names. Use Mongoid.destructive_fields to see what names this includes.
39
- too_many_nested_attribute_records:
40
- Accepting nested attributes for %{association} is limited
41
- to %{limit} records.
42
- embedded_in_must_have_inverse_of:
43
- Options for embedded_in association must include inverse_of.
44
- dependent_only_references_one_or_many:
45
- The dependent => destroy|delete option that was supplied
46
- is only valid on references_one or references_many associations.
47
- association_cant_have_inverse_of:
48
- Defining an inverse_of on this association is not allowed. Only
49
- use this option on embedded_in or references_many as array.
50
- calling_document_find_with_nil_is_invalid:
51
- Calling Document#find with nil is invalid
52
- unsaved_document:
53
- "You cannot call create or create! through a relational association
54
- relation (%{document}) who's parent (%{base}) is not already saved."
109
+ message: "Defining a field named '%{name}' is not allowed."
110
+ summary: "Defining this field would override the method '%{name}',
111
+ which would cause issues with expectations around the original
112
+ method and cause extremely hard to debug issues. The original
113
+ method was defined in:\n
114
+ \_\_Object: %{origin}\n
115
+ \_\_File: %{file}\n
116
+ \_\_Line: %{line}"
117
+ resolution: "Use Mongoid.destructive_fields to see what names are not
118
+ allowed, and don't use these names. These include names that also
119
+ conflict with core Ruby methods on Object, Module, Enumerable, or
120
+ included gems that inject methods into these or Mongoid internals."
121
+ invalid_field_option:
122
+ message: "Invalid option :%{option} provided for field :%{name}."
123
+ summary: "Mongoid requires that you only provide valid options on each
124
+ field definition in order to prevent unexpected behaviour later on."
125
+ resolution: "When defining the field :%{name} on '%{klass}', please provide
126
+ valid options for the field. These are currently: %{valid}. If you
127
+ meant to define a custom field option, please do so first like so:\n\n
128
+ \_\_Mongoid::Fields.option :%{option} do |model, field, value|\n
129
+ \_\_\_\_# Your logic here...\n
130
+ \_\_end\n
131
+ \_\_class %{klass}\n
132
+ \_\_\_\_include Mongoid::Document\n
133
+ \_\_\_\_field :%{name}, %{option}: true\n
134
+ \_\_end\n\n"
135
+ invalid_index:
136
+ message: "Invalid index specification on %{klass}: %{spec}, %{options}"
137
+ summary: "Indexes in Mongoid are defined as a hash of field name and
138
+ direction/2d pairs, with a hash for any additional options."
139
+ resolution: "Ensure that the index conforms to the correct syntax and
140
+ has the correct options.\n\n
141
+ Valid options are:\n
142
+ \_\_background: true|false\n
143
+ \_\_drop_dups: true|false\n
144
+ \_\_name: 'index_name'\n
145
+ \_\_sparse: true|false\n
146
+ \_\_unique: true|false\n\n
147
+ Valid types are: 1, -1, '2d'\n\n
148
+ Example:\n
149
+ \_\_class Band\n
150
+ \_\_\_\_include Mongoid::Document\n
151
+ \_\_\_\_index({ name: 1, label: -1 }, { sparse: true })\n
152
+ \_\_\_\_index({ location: '2d' }, { background: true })\n
153
+ \_\_end\n\n"
154
+ invalid_options:
155
+ message: "Invalid option :%{invalid} provided to relation :%{name}."
156
+ summary: "Mongoid checks the options that are passed to the relation
157
+ macros to ensure that no ill side effects occur by letting something
158
+ slip by."
159
+ resolution: "Valid options are: %{valid}, make sure these are the ones
160
+ you are using."
161
+ invalid_scope:
162
+ message: "Defining a scope of value %{value} on %{klass} is not
163
+ allowed."
164
+ summary: "Scopes in Mongoid must be either criteria objects or procs
165
+ that wrap criteria objects."
166
+ resolution: "Change the scope to be a criteria or proc wrapped
167
+ critera.\n\n
168
+ Example:\n
169
+ \_\_class Band\n
170
+ \_\_\_\_include Mongoid::Document\n
171
+ \_\_\_\_field :active, type: Boolean, default: true\n
172
+ \_\_\_\_scope :active, where(active: true)\n
173
+ \_\_\_\_scope :inactive, ->{ where(active: false) }\n
174
+ \_\_end\n\n"
175
+ invalid_storage_options:
176
+ message: "Invalid options passed to %{klass}.store_in: %{options}."
177
+ summary: "The :store_in macro takes only a hash of parameters with
178
+ the keys :database, :collection, or :session."
179
+ resolution: "Change the options passed to store_in to match the
180
+ documented API, and ensure all keys in the options hash are
181
+ symbols.\n\n
182
+ Example:\n
183
+ \_\_class Band\n
184
+ \_\_\_\_include Mongoid::Document\n
185
+ \_\_\_\_store_in collection: 'artists', database: 'secondary'\n
186
+ \_\_end\n\n"
187
+ invalid_time:
188
+ message: "'%{value}' is not a valid Time."
189
+ summary: "Mongoid tries to serialize the values for Date, DateTime, and
190
+ Time into proper UTC times to store in the database. The provided
191
+ value could not be parsed."
192
+ resolution: "Make sure to pass parsable values to the field setter
193
+ for Date, DateTime, and Time objects. When this is a String it needs
194
+ to be valid for Time.parse. Other objects must be valid to pass to
195
+ Time.local."
196
+ inverse_not_found:
197
+ message: "When adding a(n) %{klass} to %{base}#%{name}, Mongoid could
198
+ not determine the inverse foreign key to set. The attempted key was
199
+ '%{inverse}'."
200
+ summary: "When adding a document to a relation, Mongoid attempts
201
+ to link the newly added document to the base of the relation in
202
+ memory, as well as set the foreign key to link them on the
203
+ database side. In this case Mongoid could not determine what the
204
+ inverse foreign key was."
205
+ resolution: "If an inverse is not required, like a belongs_to or
206
+ has_and_belongs_to_many, ensure that :inverse_of => nil is set
207
+ on the relation. If the inverse is needed, most likely the
208
+ inverse cannot be figured out from the names of the relations and
209
+ you will need to explicitly tell Mongoid on the relation what
210
+ the inverse is.\n\n
211
+ Example:\n
212
+ \_\_class Lush\n
213
+ \_\_\_\_include Mongoid::Document\n
214
+ \_\_\_\_has_one :whiskey, class_name: \"Drink\", inverse_of: :alcoholic\n
215
+ \_\_end\n\n
216
+ \_\_class Drink\n
217
+ \_\_\_\_include Mongoid::Document\n
218
+ \_\_\_\_belongs_to :alcoholic, class_name: \"Lush\", inverse_of: :whiskey\n
219
+ \_\_end"
220
+ invalid_set_polymorphic_relation:
221
+ message: "The %{name} attribute can't be set to an instance of
222
+ %{other_klass} as %{other_klass} has multiple relations referencing
223
+ %{klass} as %{name}."
224
+ summary: "If the parent class of a polymorphic relation has multiple
225
+ definitions for the same relation, the values must be set from the
226
+ parent side and not the child side since Mongoid cannot determine
227
+ from the child side which relation to go in."
228
+ resolution: "Set the values from the parent, or redefine the relation
229
+ with only a single definition in the parent."
55
230
  mixed_relations:
56
- Referencing a(n) %{embedded} document from the %{root} document via a
57
- relational association is not allowed since the %{embedded} is embedded.
231
+ message: "Referencing a(n) %{embedded} document from the %{root}
232
+ document via a relational association is not allowed since the
233
+ %{embedded} is embedded."
234
+ summary: "In order to properly access a(n) %{embedded} from %{root}
235
+ the reference would need to go through the root document of
236
+ %{embedded}. In a simple case this would require Mongoid to store
237
+ an extra foreign key for the root, in more complex cases where
238
+ %{embedded} is multiple levels deep a key would need to be stored
239
+ for each parent up the hierarchy."
240
+ resolution: "Consider not embedding %{embedded}, or do the key
241
+ storage and access in a custom manner in the application code."
242
+ mixed_session_configuration:
243
+ message: "Both uri and standard configuration options defined for
244
+ session: '%{name}'."
245
+ summary: "Instead of simply giving uri or standard options a
246
+ preference order, Mongoid assumes that you have made a mistake in
247
+ your configuration and requires that you provide one or the other,
248
+ but not both. The options that were provided were: %{config}."
249
+ resolution: "Provide either only a uri as configuration or only
250
+ standard options."
251
+ nested_attributes_metadata_not_found:
252
+ message: "Could not find metadata for relation '%{name}' on model:
253
+ %{klass}."
254
+ summary: "When defining nested attributes for a relation, Mongoid
255
+ needs to access the metadata for the relation '%{name}' in order
256
+ if add autosave functionality to it, if applicable. Either no
257
+ relation named '%{name}' could be found, or the relation had not
258
+ been defined yet."
259
+ resolution: "Make sure that there is a relation defined named
260
+ '%{name}' on %{klass} or that the relation definition comes before
261
+ the accepts_nested_attributes_for macro in the model - order
262
+ matters so that Mongoid has access to the metadata.\n\n
263
+ Example:\n
264
+ \_\_class Band\n
265
+ \_\_\_\_include Mongoid::Document\n
266
+ \_\_\_\_has_many :albums\n
267
+ \_\_\_\_accepts_nested_attributes_for :albums\n
268
+ \_\_end\n\n"
269
+ no_default_session:
270
+ message: "No default session configuration is defined."
271
+ summary: "The configuration provided settings for: %{keys}, but
272
+ Mongoid requires a :default to be defined at minimum."
273
+ resolution: "If configuring via a mongoid.yml, ensure that within
274
+ your :sessions section a :default session is defined.\n\n
275
+ Example:\n
276
+ \_\_development:\n
277
+ \_\_\_\_sessions:\n
278
+ \_\_\_\_\_\_default:\n
279
+ \_\_\_\_\_\_\_\_hosts:\n
280
+ \_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
58
281
  no_environment:
59
- "Mongoid attempted to find the appropriate environment but no Rails.env,
60
- Sinatra::Base.environment, or RACK_ENV could be found."
282
+ message: "Could not load the configuration since no environment
283
+ was defined."
284
+ summary: "Mongoid attempted to find the appropriate environment
285
+ but no Rails.env, Sinatra::Base.environment, RACK_ENV, or
286
+ MONGOID_ENV could be found."
287
+ resolution: "Make sure some environment is set from the mentioned
288
+ options. Mongoid cannot load configuration from the yaml without
289
+ knowing which environment it is in, and we have considered
290
+ defaulting to development an undesireable side effect of this not
291
+ being defined."
292
+ no_map_reduce_output:
293
+ message: "No output location was specified for the map/reduce
294
+ operation."
295
+ summary: "When executing a map/reduce, you must provide the output
296
+ location of the results. The attempted command was: %{command}."
297
+ resolution: "Provide the location that the output of the operation
298
+ is to go by chaining an #out call to the map/reduce.\n\n
299
+ Example:\n
300
+ \_\_Band.map_reduce(map, reduce).out(inline: 1)\n\n
301
+ Valid options for the out function are:\n
302
+ \_\_inline: 1\n
303
+ \_\_merge: 'collection-name'\n
304
+ \_\_replace: 'collection-name'\n
305
+ \_\_reduce: 'collection-name'\n\n"
306
+ no_parent:
307
+ message: "Cannot persist embedded document %{klass} without a
308
+ parent document."
309
+ summary: "If the document is embedded, in order to be persisted it
310
+ must always have a reference to it's parent document. This is
311
+ most likely cause by either calling %{klass}.create or
312
+ %{klass}.create! without setting the parent document as an
313
+ attribute."
314
+ resolution: "Ensure that you've set the parent relation if
315
+ instantiating the embedded document direcly, or always create new
316
+ embedded documents via the parent relation."
317
+ no_session_config:
318
+ message: "No configuration could be found for a session named
319
+ '%{name}'."
320
+ summary: "When attempting to create the new session, Mongoid could
321
+ not find a session configuration for the name: '%{name}'. This is
322
+ necessary in order to know the host, port, and options needed
323
+ to connect."
324
+ resolution: "Double check your mongoid.yml to make sure under the
325
+ sessions key that a configuration exists for '%{name}'. If you
326
+ have set the configuration programatically, ensure that '%{name}'
327
+ exists in the configuration hash."
328
+ no_sessions_config:
329
+ message: "No sessions configuration provided."
330
+ summary: "Mongoid's configuration requires that you provide details
331
+ about each session that can be connected to, and requires in
332
+ the sessions config at least 1 default session to exist."
333
+ resolution: "Double check your mongoid.yml to make sure that you
334
+ have a top-level sessions key with at least 1 default session
335
+ configuration for it. You can regenerate a new mongoid.yml for
336
+ assistance via `rails g mongoid:config`.\n\n
337
+ Example:\n
338
+ \_\_development:\n
339
+ \_\_\_\_sessions:\n
340
+ \_\_\_\_\_\_default:\n
341
+ \_\_\_\_\_\_\_\_database: mongoid_dev\n
342
+ \_\_\_\_\_\_\_\_hosts:\n
343
+ \_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
344
+ no_session_database:
345
+ message: "No database provided for session configuration: :%{name}."
346
+ summary: "Each session configuration must provide a database so Mongoid
347
+ knows where the default database to persist to. What was provided
348
+ was: %{config}."
349
+ resolution: "If configuring via a mongoid.yml, ensure that within
350
+ your :%{name} section a :database value for the session's default
351
+ database is defined.\n\n
352
+ Example:\n
353
+ \_\_development:\n
354
+ \_\_\_\_sessions:\n
355
+ \_\_\_\_\_\_%{name}:\n
356
+ \_\_\_\_\_\_\_\_database: my_app_db\n
357
+ \_\_\_\_\_\_\_\_hosts:\n
358
+ \_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
359
+ no_session_hosts:
360
+ message: "No hosts provided for session configuration: :%{name}."
361
+ summary: "Each session configuration must provide hosts so Mongoid
362
+ knows where the database server is located. What was provided
363
+ was: %{config}."
364
+ resolution: "If configuring via a mongoid.yml, ensure that within
365
+ your :%{name} section a :hosts value for the session hosts is
366
+ defined.\n\n
367
+ Example:\n
368
+ \_\_development:\n
369
+ \_\_\_\_sessions:\n
370
+ \_\_\_\_\_\_%{name}:\n
371
+ \_\_\_\_\_\_\_\_database: my_app_db\n
372
+ \_\_\_\_\_\_\_\_hosts:\n
373
+ \_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
374
+ readonly_attribute:
375
+ message: "Attempted to set the readonly attribute '%{name}' with
376
+ the value: %{value}."
377
+ summary: "Attributes flagged as readonly via Model.attr_readonly
378
+ can only have values set when the document is a new record."
379
+ resolution: "Don't define '%{name}' as readonly, or do not attempt
380
+ to update it's value after the document is persisted."
61
381
  scope_overwrite:
62
- "Cannot create scope :%{scope_name}, because of existing method
63
- %{model_name}.%{scope_name}."
64
- blank_on_locale: "can't be blank in %{location}"
382
+ message: "Cannot create scope :%{scope_name}, because of existing
383
+ method %{model_name}.%{scope_name}."
384
+ summary: "When defining a scope that conflicts with a method that
385
+ already exists on the model, this error will get raised if
386
+ Mongoid.scope_overwrite_exception is set to true."
387
+ resolution: "Change the name of the scope so it does not conflict
388
+ with the already defined method %{model_name}, or set the
389
+ configuration option Mongoid.scope_overwrite_exception to false,
390
+ which is it's default. In this case a warning will be logged."
391
+ taken:
392
+ "is already taken"
393
+ too_many_nested_attribute_records:
394
+ message: "Accepting nested attributes for %{association} is limited
395
+ to %{limit} records."
396
+ summary: "More documents were sent to be processed than the allowed
397
+ limit."
398
+ resolution: "The limit is set as an option to the macro, for example:
399
+ accepts_nested_attributes_for :%{association}, limit: %{limit}.
400
+ Consider raising this limit or making sure no more are sent than
401
+ the set value."
402
+ unknown_attribute:
403
+ message: "Attempted to set a value for '%{name}' which is not
404
+ allowed on the model %{klass}."
405
+ summary: "When setting Mongoid.allow_dynamic_fields to false and the
406
+ attribute does not already exist in the attributes hash, attempting
407
+ to call %{klass}#%{name}= for it is not allowed. This is also
408
+ triggered by passing the attribute to any method that accepts an
409
+ attributes hash, and is raised instead of getting a NoMethodError."
410
+ resolution: "You can set Mongoid.allow_dynamic_fields to true if you
411
+ expect to be writing values for undefined fields often."
412
+ unsaved_document:
413
+ message: "Attempted to save %{document} before the parent %{base}."
414
+ summary: "You cannot call create or create! through the
415
+ relation (%{document}) who's parent (%{base}) is
416
+ not already saved. This would case the database to be out of sync
417
+ since the child could potentially reference a nonexistant parent."
418
+ resolution: "Make sure to only use create or create! when the parent
419
+ document %{base} is persisted."
420
+ unsupported_version:
421
+ message: "MongoDB %{version} not supported, please upgrade to
422
+ %{mongo_version}."
423
+ summary: "Mongoid is relying on features that were introduced in
424
+ MongoDB %{mongo_version} and would cause unexpected behaviour or errors
425
+ on version %{version}."
426
+ resolution: "Upgrade your MongoDB instances or keep Mongoid on your
427
+ previous version."
428
+ unsupported_javascript:
429
+ message: "Executing Javascript $where selector on an embedded criteria
430
+ is not supported."
431
+ summary: "Mongoid only supports providing a hash of arguments to
432
+ #where criterion on embedded documents. Since %{klass} is embedded,
433
+ the expression %{javascript} is not allowed."
434
+ resolution: "Please provide a standard hash to #where when the criteria
435
+ is for an embedded relation."
436
+ validations:
437
+ message: "Validation of %{document} failed."
438
+ summary: "The following errors were found: %{errors}"
439
+ resolution: "Try persisting the document with valid data or remove
440
+ the validations."
441
+ versioning_not_on_root:
442
+ message: "Versioning not allowed on embedded document: %{klass}."
443
+ summary: "Mongoid::Versioning behaviour is only allowed on documents
444
+ that are the root document in the hierarchy."
445
+ resolution: "Remove the versioning from the embedded %{klass} or
446
+ consider moving it to a root location in the hierarchy if
447
+ versioning is needed."
448
+ delete_restriction:
449
+ message: "Cannot delete %{document} because of dependent '%{relation}'."
450
+ summary: "When defining '%{relation}' with a :dependent => :restrict,
451
+ Mongoid will raise an error when attempting to delete the
452
+ %{document} when the child '%{relation}' still has documents in it."
453
+ resolution: "Don't attempt to delete the parent %{document} when
454
+ it has children, or change the dependent option on the relation."