Project create
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
class Project < ApplicationRecord
|
||||
validates :name, :code, presence: true
|
||||
validates :code, exclusion: { in: %w[new] }, uniqueness: true
|
||||
|
||||
has_many :tasks
|
||||
|
||||
has_rich_text :description
|
||||
|
||||
before_validation :lowercase_code
|
||||
|
||||
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