-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
When using
Unable to find source-code formatter for language: accepts_nested_attributes_for```. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
and updating an existing nesting, Mongoid fires a Mass-Assignment warning. On a more strict environment this warning might turn into exception (see example possible patch below).
However it seems like ActiveRecord is removing the ID field once the record has been and retrieved from the DB so that it does not assign that same ID field again.
Example code
rb
class Comment
include Mongoid::Document
field :msg
belongs_to :test_user
end
class TestUser
include Mongoid::Document
has_many :comments
accepts_nested_attributes_for :comments, allow_destroy: true
end
u=TestUser.create!()
comment = u.comments.create!(msg: 'Hello')
u.update_attributes(comments_attributes:
)
DEBUG WARNING: Can't mass-assign protected attributes: id
`