Skip to content

ActiveModel::MissingAttributeError on custom select #190

@jrochkind

Description

@jrochkind

originally from @guilhermegazzinelli


Hi Jonathan,

I had the same issue, but with custom types. The error is as follows:

*** ActiveModel::MissingAttributeError Exception: missing attribute: settings

In another investigation I got:

ActiveModel::MissingAttributeError: missing attribute: settings from /(...)/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/activemodel-7.0.4.2/lib/active_model/attribute.rb:226:in 'value'

This appeared when I do:

Form.select(:id, :name).last

I'll try to investigate deeper and post here my findings.

Code Excerpt

class Form < ApplicationRecord
  include AttrJson::Record
  attr_json_config(default_container_attribute: :settings)
  attr_json :form_settings, Json::FormSettings.to_type, default: nil 
  attr_json :name,:string, default: "Default name"
end
class Json::FormSettings
  include AttrJson::Model

  attr_json :name, :string, default: nil #
  attr_json :department, ActiveModel::Type::Value.new, array: true,  default: nil #
end

More info:

  • Rails 7.0.4.2
  • Bundler version 2.4.6
  • attr_json (2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions