In a simple Rails 7 model I have:
has_one_attached :file, strict_loading: true
Now, I want to create a new record:
Model.create(name: 'test', file: params[:file])
But this leads to a ActiveRecord::StrictLoadingViolationError →
Model
is marked for strict_loading. The ActiveStorage::Attachment
association named :file_attachment
cannot be lazily loaded.
I’ve tried: Model.with_attached_file.create() and variations with #new and #save but that does not help.
Is there a way? Or is this a bug?
Jan