rubocop corrections
This commit is contained in:
parent
c63c6bc448
commit
de29815686
72 changed files with 468 additions and 311 deletions
|
@ -1,23 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
def update(*args)
|
||||
result = super(*args)
|
||||
AuditRecord.create(model: self.class, action: 'update', params: self.to_json)
|
||||
AuditRecord.create(model: self.class, action: 'update', params: to_json)
|
||||
result
|
||||
end
|
||||
|
||||
def save(*args)
|
||||
result = super(*args)
|
||||
AuditRecord.create(model: self.class, action: 'save', params: self.to_json)
|
||||
AuditRecord.create(model: self.class, action: 'save', params: to_json)
|
||||
result
|
||||
end
|
||||
|
||||
def self.create(*args)
|
||||
result = super(*args)
|
||||
AuditRecord.create(model: self.class, action: 'create', params: result.to_json)
|
||||
result
|
||||
end
|
||||
|
||||
def decrement!(*args)
|
||||
result = super(*args)
|
||||
AuditRecord.create(model: self.class, action: 'decrement!', params: self.to_json)
|
||||
AuditRecord.create(model: self.class, action: 'decrement!', params: to_json)
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AuditRecord < ActiveRecord::Base
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Author < ApplicationRecord
|
||||
validates :first_name, presence: true
|
||||
validates :last_name, presence: true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Book < ApplicationRecord
|
||||
has_and_belongs_to_many :authors
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class User < ApplicationRecord
|
||||
has_and_belongs_to_many :books
|
||||
|
||||
has_secure_password
|
||||
has_secure_password :recovery_password, validations: false
|
||||
enum role: [:customer, :admin], _default: :customer
|
||||
enum status: [:ready, :blocked], _default: :ready
|
||||
enum role: %i[customer admin], _default: :customer
|
||||
enum status: %i[ready blocked], _default: :ready
|
||||
|
||||
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validates :role, presence: true
|
||||
|
@ -12,6 +14,6 @@ class User < ApplicationRecord
|
|||
validates :password, {
|
||||
presence: true,
|
||||
length: { minimum: 8 },
|
||||
if: lambda{ new_record? || !password.nil? }
|
||||
if: -> { new_record? || !password.nil? }
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue