Skip to content

Commit

Permalink
貸出管理のバリデーションを追加。
Browse files Browse the repository at this point in the history
  • Loading branch information
mikoto2000 committed Sep 9, 2024
1 parent e4d7d9c commit f783be3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
26 changes: 12 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -328,8 +325,9 @@ DEPENDENCIES
brakeman
capybara
cssbundling-rails
date_validator
debug
erb_lint!
erb_lint
importmap-rails
jbuilder
pagy
Expand Down
1 change: 1 addition & 0 deletions app/models/book_stock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/models/book_stock_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions app/models/lending_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/models/lending_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f783be3

Please sign in to comment.