-
|
In tests, I sometimes need to create records with specific values, such as a past class User < Marten::Model
with_timestamp_fields
field :id, :big_int, primary_key: true, auto: true
field :name, :string, max_size: 255, null: true, blank: true
end
User.create!(created_at: 30.days.ago)Or I may need to set a specific User.get_or_create!(id: 3, name: "Others")However, I’ve noticed that the database seems to ignore user-supplied values for these fields. Have you encountered this before? Do you know of any workarounds? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hey! 👋 Manually specifying IDs is something that is not supported at the moment (we can consider adding support for this, though!). The user.update!(created_at: 30.days.ago) |
Beta Was this translation helpful? Give feedback.
Hey! 👋
Manually specifying IDs is something that is not supported at the moment (we can consider adding support for this, though!).
The
created_atattribute is usually intended to be populated automatically, and as such, it's not possible to manually specify it. That said you can still update thecreated_atvalue by manually updating the record if necessary: