Added Rubocop and initial config
This commit is contained in:
+5
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user