add custom modes
This commit is contained in:
parent
411b738c2f
commit
fe52089c38
5 changed files with 38 additions and 1 deletions
3
app/models/mode.rb
Normal file
3
app/models/mode.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
class Mode < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
end
|
||||||
11
db/migrate/20260314144625_create_modes.rb
Normal file
11
db/migrate/20260314144625_create_modes.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateModes < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
create_table :modes do |t|
|
||||||
|
t.string :label
|
||||||
|
t.string :color
|
||||||
|
t.references :user, null: false, foreign_key: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
12
db/schema.rb
generated
12
db/schema.rb
generated
|
|
@ -10,7 +10,16 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2026_02_26_101258) do
|
ActiveRecord::Schema[8.0].define(version: 2026_03_14_144625) do
|
||||||
|
create_table "modes", force: :cascade do |t|
|
||||||
|
t.string "label"
|
||||||
|
t.string "color"
|
||||||
|
t.integer "user_id", null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_modes_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "moods", force: :cascade do |t|
|
create_table "moods", force: :cascade do |t|
|
||||||
t.string "mode"
|
t.string "mode"
|
||||||
t.datetime "recorded_at"
|
t.datetime "recorded_at"
|
||||||
|
|
@ -52,6 +61,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_02_26_101258) do
|
||||||
t.index ["email_address"], name: "index_users_on_email_address", unique: true
|
t.index ["email_address"], name: "index_users_on_email_address", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_foreign_key "modes", "users"
|
||||||
add_foreign_key "moods", "users"
|
add_foreign_key "moods", "users"
|
||||||
add_foreign_key "rfid_tags", "users"
|
add_foreign_key "rfid_tags", "users"
|
||||||
add_foreign_key "sessions", "users"
|
add_foreign_key "sessions", "users"
|
||||||
|
|
|
||||||
8
spec/factories/modes.rb
Normal file
8
spec/factories/modes.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
FactoryBot.define do
|
||||||
|
factory :mode do
|
||||||
|
label { "MyString" }
|
||||||
|
slug { "MyString" }
|
||||||
|
color { "MyString" }
|
||||||
|
user { nil }
|
||||||
|
end
|
||||||
|
end
|
||||||
5
spec/models/mode_spec.rb
Normal file
5
spec/models/mode_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Mode, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Loading…
Add table
Reference in a new issue