Today I encountered a tricky problem in a seemingly simple "one record is not showing up in #index" bugfix task.
The problem stems from this data situation:
Task.pluck(:project_version_id, :is_actual)
#=> [
[1, true],
[nil, true]
]
Both versioned and non-versioned records can be :actual, can this be right?
Thinking about it, I came to the realization that working with versioned data requires clear answers to these questions:
- Are 'draft' data ever persisted in a sort of 'lobby'?
- What is more important - accessing possible draft data or possible latest approved/actual version?
- What operation(s) result in new version(s)?
Depending on the answers, you can get one of these two systems:
The key difference for developers is the meaning and importance of unversioned data. In version case, regular data are the actual and special access is needed for historic version data. Whereas in approval pattern it's the opposite - unversioned data is less important, since it's not yet 'approved'.
Naturally, approval workflow will be harder to reason about and will require careful development to communicate that plain project.tasks.actual is not quite project.last_approved_version.tasks.

Top comments (1)
Really interesting read ! The ambiguity around is_actual is a great example of how mixing versioning and approval concepts can get confusing fast.
Feels like “actual” is trying to represent too many things at once, maybe that’s where the issue starts.