I have simple class:
class Settings
include ActiveModel::Model, ActiveModel::Attributes
attribute :display_raw_results, :boolean, default: false
end
When I try to initialize it with empty hash it works.
Settings.new
# or
Settings.new({})
But if I pass a value in this hash it fails with expection
Settings.new(display_raw_results: true)
# results in: undefined method `write_from_user' for nil:NilClass
What I'm doing wrong?
Turns out the problem was in one line include
. After including modules separately it works as expected.
class Settings
include ActiveModel::Model
include ActiveModel::Attributes
attribute :display_raw_results, :boolean, default: false
end