Added Rubocop and initial config

This commit is contained in:
2025-07-10 15:30:00 +03:00
parent 864769e70a
commit 42d45853ff
8 changed files with 140 additions and 35 deletions
+5 -10
View File
@@ -1,23 +1,18 @@
# frozen_string_literal: true
class Project < ApplicationRecord
validates :name, :code, presence: true
validates :code, exclusion: { in: %w[new] }, uniqueness: true
has_many :tasks
has_many :tasks, dependent: :restrict_with_exception
has_rich_text :description
before_validation :lowercase_code
normalizes :code, with: ->(code) { code.strip.downcase }
def to_param
return unless id
code
end
private
def lowercase_code
return if code.blank?
self.code = self.code.downcase
end
end