-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Attributes
ActionController::Parameters need a mongoizer to convert them into Hash; currently an error is raised.
- Note that a demongoize method is not needed here; the conversion should be one-way only.
I have raised https://github.com/mongodb/mongoid/pull/5237 for this.
The below demonstrates the issue.
require 'mongoid' require 'action_controller' class Company include Mongoid::Document field :name, type: String, localize: true end params = ActionController::Parameters.new({ name_translations: { en: "Foobar", fr: "Bazqux" } }).permit! company = Company.new company.name_translations = params #=> Traceback (most recent call last): 3: from C:/ruby30/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>' 2: from (irb):20:in `<main>' 1: from C:/ruby30/lib/ruby/gems/3.0.0/gems/mongoid-7.4.0/lib/mongoid/fields.rb:577:in `block (2 levels) in create_translations_setter' NoMethodError (undefined method `update_values' for #<ActionController::Parameters {"name_translations"=>#<ActionController::Parameters {"en"=>"Foobar", "fr"=>"Bazqux"} permitted: true>} permitted: true>)