lexivo/app/models/word.rb
Fibe Agent e9f5d8ece2
Some checks failed
CI / Lint & Test (push) Has been cancelled
Deploy Status Page / Build & Deploy (push) Has been cancelled
Lexivo: vocabulary learning app with SM-2 spaced repetition
- Word import (multi-format: word, word-def, word:def, word|def)
- Flashcard filter UI (swipe + keyboard arrows + Space to flip)
- SM-2 spaced repetition review queue
- Stimulus flashcard controller with 3D flip animation
2026-04-22 15:02:45 +00:00

22 lines
614 B
Ruby

# frozen_string_literal: true
class Word < ApplicationRecord
has_one :review, dependent: :destroy
validates :text, presence: true, uniqueness: { case_sensitive: false }
validates :text, length: { maximum: 255 }
after_create :create_initial_review
scope :unseen, -> { joins(:review).where(reviews: { status: "new" }) }
scope :known, -> { joins(:review).where(reviews: { status: "known" }) }
scope :learning, -> { joins(:review).where(reviews: { status: "learning" }) }
scope :by_text, -> { order(:text) }
private
def create_initial_review
create_review!(status: "new")
end
end