From 6a9c901eae2e2f052275ebe4270e1c45b1cb4b41 Mon Sep 17 00:00:00 2001 From: DrumsnChocolate Date: Sun, 19 Jan 2025 14:39:15 +0100 Subject: [PATCH] Revert "turns out this was manually disabled" This reverts commit 7330b686a8d3bcc864462466b4fecb76af4035a0. --- app/models/product.rb | 7 +++++++ app/views/price_lists/index.html.erb | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/product.rb b/app/models/product.rb index f123e880b..8082251ac 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -6,6 +6,7 @@ class Product < ApplicationRecord has_many :price_lists, through: :product_prices, dependent: :restrict_with_error validates :name, :category, presence: true + validate :name_readonly accepts_nested_attributes_for :product_prices, allow_destroy: true @@ -18,4 +19,10 @@ def t_category end private + + def name_readonly + return if new_record? + + errors.add(:name, 'is readonly') if name_changed? + end end diff --git a/app/views/price_lists/index.html.erb b/app/views/price_lists/index.html.erb index 8a0da018b..2998d0dba 100644 --- a/app/views/price_lists/index.html.erb +++ b/app/views/price_lists/index.html.erb @@ -25,11 +25,11 @@
<% end %> - + @@ -60,7 +60,7 @@
- +