Skip to content

Commit

Permalink
Merge pull request #2015 from tf/errors-add
Browse files Browse the repository at this point in the history
Fix Active Record errors deprecation warning
  • Loading branch information
tf authored Oct 16, 2023
2 parents 09d996e + 89c23cc commit 90c7dad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/pageflow/reusable_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def parent_allows_type_for_nesting
file_type_of_parent = Pageflow.config.file_types.find_by_model!(parent_class)
models_of_nested_file_types = file_type_of_parent.nested_file_types.map(&:model)
unless models_of_nested_file_types.include?(self.class)
errors[:base] << 'File type of provided parent file does not permit nesting files of '\
"type #{self.class.name}"
errors.add(:base, 'File type of provided parent file does not permit nesting files of '\
"type #{self.class.name}")
end
end
end

def parent_belongs_to_same_entry
if parent_file.present?
unless parent_file.using_entries.include?(entry)
errors[:base] << 'Parent file does not belong to same entry as nested file'
errors.add(:base, 'Parent file does not belong to same entry as nested file')
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions app/models/pageflow/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class Membership < ApplicationRecord
private

def account_membership_exists
errors[:base] << 'Entry Membership misses presupposed Membership on account of entry' if
user.present? && !user.accounts.include?(entity.account)
return if user.blank? || user.accounts.include?(entity.account)

errors.add(:base, 'Entry Membership misses presupposed Membership on account of entry')
end

def on_entry?
Expand Down

0 comments on commit 90c7dad

Please sign in to comment.