diff options
author | Marius Peter <marius.peter@tutanota.com> | 2024-12-29 15:14:43 +0100 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2024-12-29 15:14:43 +0100 |
commit | be2a93525069de2dfa3c23b0c23e7a9f7ad4c03d (patch) | |
tree | b5493e9d35d024ce7be072ec2168b4a98ba0e63f /app/models |
First commit.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_record.rb | 3 | ||||
-rw-r--r-- | app/models/concerns/.keep | 0 | ||||
-rw-r--r-- | app/models/current.rb | 4 | ||||
-rw-r--r-- | app/models/score.rb | 6 | ||||
-rw-r--r-- | app/models/scoring_criterium.rb | 9 | ||||
-rw-r--r-- | app/models/session.rb | 3 | ||||
-rw-r--r-- | app/models/tartiflette.rb | 3 | ||||
-rw-r--r-- | app/models/user.rb | 6 |
8 files changed, 34 insertions, 0 deletions
diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..b63caeb --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/models/concerns/.keep diff --git a/app/models/current.rb b/app/models/current.rb new file mode 100644 index 0000000..2bef56d --- /dev/null +++ b/app/models/current.rb @@ -0,0 +1,4 @@ +class Current < ActiveSupport::CurrentAttributes + attribute :session + delegate :user, to: :session, allow_nil: true +end diff --git a/app/models/score.rb b/app/models/score.rb new file mode 100644 index 0000000..5147ce0 --- /dev/null +++ b/app/models/score.rb @@ -0,0 +1,6 @@ +class Score < ApplicationRecord + belongs_to :tartiflette + belongs_to :scoring_criterium + + validates :value, presence: true, inclusion: { in: 1..5 } +end diff --git a/app/models/scoring_criterium.rb b/app/models/scoring_criterium.rb new file mode 100644 index 0000000..a94ad77 --- /dev/null +++ b/app/models/scoring_criterium.rb @@ -0,0 +1,9 @@ +class ScoringCriterium < ApplicationRecord + has_many :scores, dependent: :destroy + + validates :name, :category, presence: true + + def self.grouped_by_category + ScoringCriterium.all.group_by(&:category) + end +end diff --git a/app/models/session.rb b/app/models/session.rb new file mode 100644 index 0000000..cf376fb --- /dev/null +++ b/app/models/session.rb @@ -0,0 +1,3 @@ +class Session < ApplicationRecord + belongs_to :user +end diff --git a/app/models/tartiflette.rb b/app/models/tartiflette.rb new file mode 100644 index 0000000..4abfe74 --- /dev/null +++ b/app/models/tartiflette.rb @@ -0,0 +1,3 @@ +class Tartiflette < ApplicationRecord + has_many :scores +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..c88d5b0 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User < ApplicationRecord + has_secure_password + has_many :sessions, dependent: :destroy + + normalizes :email_address, with: ->(e) { e.strip.downcase } +end |