mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 03:31:42 +00:00
no fallar si el atributo no existe
fallaba al encontrar la licencia
This commit is contained in:
parent
58d7fabed4
commit
cc9c3a38b9
1 changed files with 4 additions and 1 deletions
|
@ -72,8 +72,11 @@ class PostRelation < Array
|
|||
# Encuentra el primer post por el valor de un atributo
|
||||
# XXX: Acepta cualquier atributo
|
||||
def find_by(**args)
|
||||
attr = args.first.first
|
||||
|
||||
find_generic do |p|
|
||||
p.public_send(args.first.first).try(:value) == args.first.last
|
||||
p.attribute?(attr) &&
|
||||
p.public_send(attr).value == args.first.last
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue