Business Logic: A user can only create one journal entry per day. Before a record can be created, it must query the records to determine if the record has already been created to date.
I was looking for tips on how best to approach this. I had several ideas on how to implement it on the client side, but I would really like it to be tested at the model level. Any help would be appreciated.
Create a unique index in the log table:
add_index :journal_entries, [:user_id, :created_on], unique: true
user_id , , . , created_on date, datetime.
created_on
date
datetime
100% , .
Source: https://habr.com/ru/post/1533981/More articles:How to compute Lisp code inside a reader macro? - lispBullying Custom File Storage - djangoInjection controllers in controllers no longer work during initialization (canary) - ember.js`foreach` on a parallel set never starts - collectionsCode matching with Nhibernate 3.2 sqlite blob field with byte [] does not work - c #R shiny multiple choice with scroll bar - rhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1533983/how-to-flex-child-elements-to-the-height-of-their-heighest-sibling-inside-a-parent-with-overflowscroll&usg=ALkJrhhCRAGqQXwXh1GWM49SfSqiXK4PKQDifference Between State Iterators and Lost Users in Lua - luaElastic Search _suggest caching - elasticsearchhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1533986/how-to-mock-a-repository-to-use-as-an-argument-for-a-controller&usg=ALkJrhiXUU3bsyD0xkHU16F0L1vFD3JnWAAll Articles