-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified the `request_distributions` schema to replace the `area` with `positions_on_bench` and `dimensions`. Simplified routes by adjusting the `request_distributions` index action.
- Loading branch information
1 parent
62be386
commit 4201ad3
Showing
21 changed files
with
519 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support/concern' | ||
|
||
module ValidateDimensionsConcern | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
validates :dimensions, | ||
presence: true, | ||
length: { is: 2, | ||
message: I18n.t('activerecord.errors.concern.attributes.dimensions.incorrect_size') } | ||
validate :dimensions_must_be_strictly_positive | ||
|
||
private | ||
|
||
def dimensions_must_be_strictly_positive | ||
return unless dimensions | ||
|
||
return unless dimensions.any? { |d| d <= 0 } | ||
|
||
errors.add(:dimensions, I18n.t('activerecord.errors.concern.attributes.dimensions.not_positive')) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class UpdateRequestDistributions < ActiveRecord::Migration[7.2] | ||
def change | ||
change_table :request_distributions, bulk: true do |t| | ||
t.remove :area, type: :decimal | ||
t.integer :positions_on_bench, array: true | ||
t.integer :dimensions, array: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.