Compare commits

..

No commits in common. "022b58bb3867a68784e9f32d26898b1a780962be" and "70e9f742073bf9dd1ffdce21c01b53b537f59e8d" have entirely different histories.

6 changed files with 17 additions and 10 deletions

View File

@ -2,7 +2,7 @@
class CaptchaController < ApplicationController class CaptchaController < ApplicationController
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
skip_before_action :set_tenant
def create def create
id = LibreCaptcha.new.get_id id = LibreCaptcha.new.get_id
render json: { render json: {

View File

@ -7,7 +7,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
before_action :validate_captcha!, only: :create before_action :validate_captcha!, only: :create
def create def create
wedding = Wedding.create(slug: params[:slug]) wedding = Wedding.create(wedding_params)
unless wedding.persisted? unless wedding.persisted?
render json: { errors: wedding.errors.full_messages }, status: :unprocessable_entity render json: { errors: wedding.errors.full_messages }, status: :unprocessable_entity
return return
@ -22,7 +22,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
private private
def set_tenant def wedding_params
set_current_tenant(nil) { slug: params[:slug], **params.expect(wedding: :date) }
end end
end end

View File

@ -5,6 +5,7 @@
# Table name: weddings # Table name: weddings
# #
# id :uuid not null, primary key # id :uuid not null, primary key
# date :date not null
# slug :string not null # slug :string not null
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
@ -16,5 +17,6 @@
class Wedding < ApplicationRecord class Wedding < ApplicationRecord
SLUG_REGEX = /[a-z\d-]+/ SLUG_REGEX = /[a-z\d-]+/
validates :date, presence: true
validates :slug, presence: true, uniqueness: true, format: { with: /\A#{SLUG_REGEX}\z/ } validates :slug, presence: true, uniqueness: true, format: { with: /\A#{SLUG_REGEX}\z/ }
end end

View File

@ -1,5 +0,0 @@
class RemoveWeddingDate < ActiveRecord::Migration[8.0]
def change
remove_column :weddings, :date, :date, null: false
end
end

5
db/schema.rb generated
View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# This file is auto-generated from the current state of the database. Instead # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.
@ -10,7 +12,7 @@
# #
# 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: 2024_12_07_112305) do ActiveRecord::Schema[8.0].define(version: 2024_11_30_185731) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql" enable_extension "pg_catalog.plpgsql"
@ -220,6 +222,7 @@ ActiveRecord::Schema[8.0].define(version: 2024_12_07_112305) do
create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "slug", null: false t.string "slug", null: false
t.date "date", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["slug"], name: "index_weddings_on_slug", unique: true t.index ["slug"], name: "index_weddings_on_slug", unique: true

View File

@ -24,6 +24,13 @@ RSpec.describe 'users/registrations', type: :request do
password_confirmation: SwaggerResponseHelper::PASSWORD password_confirmation: SwaggerResponseHelper::PASSWORD
} }
}, },
wedding: {
type: :object,
required: %i[date],
properties: {
date: { type: :string, format: :date},
}
},
**Swagger::Schema::CAPTCHA **Swagger::Schema::CAPTCHA
} }
} }