- 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
22 lines
614 B
Ruby
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
|