mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 17:51:41 +00:00
Merge branch 'validar-has-many' into 'rails'
validar de más has_many See merge request sutty/sutty!34
This commit is contained in:
commit
918dd4cb10
1 changed files with 0 additions and 12 deletions
|
@ -6,14 +6,6 @@
|
|||
# Localmente tenemos un Array de UUIDs. Remotamente tenemos una String
|
||||
# apuntando a un Post, que se mantiene actualizado como el actual.
|
||||
class MetadataHasMany < MetadataRelatedPosts
|
||||
def validate
|
||||
super
|
||||
|
||||
errors << I18n.t('metadata.has_many.missing_posts') unless posts_exist?
|
||||
|
||||
errors.empty?
|
||||
end
|
||||
|
||||
# Todos los Post relacionados
|
||||
def has_many
|
||||
return default_value if value.blank?
|
||||
|
@ -65,8 +57,4 @@ class MetadataHasMany < MetadataRelatedPosts
|
|||
def related_methods
|
||||
@related_methods ||= %i[has_many had_many].freeze
|
||||
end
|
||||
|
||||
def posts_exist?
|
||||
has_many.size == sanitize(value).size
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue