From f783be38ef6219f326f30ef9ac4be723f87cdffe Mon Sep 17 00:00:00 2001 From: mikoto2000 Date: Mon, 9 Sep 2024 01:58:40 +0000 Subject: [PATCH] =?UTF-8?q?=E8=B2=B8=E5=87=BA=E7=AE=A1=E7=90=86=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 3 ++- Gemfile.lock | 26 ++++++++++++-------------- app/models/book_stock.rb | 1 + app/models/book_stock_status.rb | 2 ++ app/models/lending_set.rb | 6 ++++++ app/models/lending_status.rb | 2 ++ 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index 790ba17..9a06562 100644 --- a/Gemfile +++ b/Gemfile @@ -66,4 +66,5 @@ gem "rubocop-performance", group: "development" gem "rubocop-minitest", group: "development" gem "rubocop-i18n", group: "development" gem "rubocop-thread_safety", group: "development" -gem "erb_lint", github: "mikoto2000/erb-lint", ref: "9ef15e20da0ad46077c88b73bac06e4edd15d2c2" +gem "erb_lint", group: "development" +gem "date_validator" diff --git a/Gemfile.lock b/Gemfile.lock index 0ed867e..9cb48ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,3 @@ -GIT - remote: https://github.com/mikoto2000/erb-lint.git - revision: 9ef15e20da0ad46077c88b73bac06e4edd15d2c2 - ref: 9ef15e20da0ad46077c88b73bac06e4edd15d2c2 - specs: - erb_lint (0.4.0) - activesupport - better_html (>= 2.0.1) - parser (>= 2.7.1.4) - rainbow - rubocop - smart_properties - GEM remote: https://rubygems.org/ specs: @@ -117,10 +104,20 @@ GEM cssbundling-rails (1.4.1) railties (>= 6.0.0) date (3.3.4) + date_validator (0.12.0) + activemodel (>= 3) + activesupport (>= 3) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) drb (2.2.1) + erb_lint (0.4.0) + activesupport + better_html (>= 2.0.1) + parser (>= 2.7.1.4) + rainbow + rubocop + smart_properties erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) @@ -328,8 +325,9 @@ DEPENDENCIES brakeman capybara cssbundling-rails + date_validator debug - erb_lint! + erb_lint importmap-rails jbuilder pagy diff --git a/app/models/book_stock.rb b/app/models/book_stock.rb index 61d7382..5c39bca 100644 --- a/app/models/book_stock.rb +++ b/app/models/book_stock.rb @@ -2,6 +2,7 @@ class BookStock < ApplicationRecord def self.ransackable_attributes(_auth_object = nil) %w[book_master_id book_stock_status_id memo id created_at updated_at] end + belongs_to :book_master belongs_to :book_stock_status diff --git a/app/models/book_stock_status.rb b/app/models/book_stock_status.rb index d323b28..4b686f4 100644 --- a/app/models/book_stock_status.rb +++ b/app/models/book_stock_status.rb @@ -2,4 +2,6 @@ class BookStockStatus < ApplicationRecord def self.ransackable_attributes(_auth_object = nil) %w[name id created_at updated_at] end + + validates :name, presence: true, uniqueness: true end diff --git a/app/models/lending_set.rb b/app/models/lending_set.rb index 25b9a60..e4838af 100644 --- a/app/models/lending_set.rb +++ b/app/models/lending_set.rb @@ -5,6 +5,12 @@ def self.ransackable_attributes(_auth_object = nil) def self.ransackable_associations(auth_object = nil) ["book_stocks", "customer", "lending", "lending_status"] end + + validates :book_stocks, presence: true + validates :lend_start_date, presence: true, date: true + validates :return_deadline_date, presence: true, date: { after: :lend_start_date } + validates :return_date, date: { allow_blank: true } + belongs_to :customer belongs_to :lending_status diff --git a/app/models/lending_status.rb b/app/models/lending_status.rb index 76093a7..2926e1b 100644 --- a/app/models/lending_status.rb +++ b/app/models/lending_status.rb @@ -2,4 +2,6 @@ class LendingStatus < ApplicationRecord def self.ransackable_attributes(_auth_object = nil) %w[name id created_at updated_at] end + + validates :name, presence: true, uniqueness: true end