Automatic created_at and updated_at


I see in the rom-rails there is a way to do this, I am not on rails fortunately.

What would be the best way to have these fields and have them populated and the updated_at field populated on save? at the moment I am manually doing this in my models to_h method, and then using this to persist for example:

class User

def to_h

created_at: @created_at ||

Which is a bit clunky for me and I could not find any examples out there demonstrating a solution.


Hey Stefan,

Sorry for this late reply. You can use repository with changesets which comes with built-in support for adding timestamps. There’s an example here.

Hope this helps :slight_smile:


The valid link is now