5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 09:26:22 +00:00

Merge branch 'writable' into rails

This commit is contained in:
f 2021-04-21 10:19:57 -03:00
commit 56725f3bd7

View file

@ -348,6 +348,8 @@ class Post
def update_attributes(hashable) def update_attributes(hashable)
hashable.to_hash.each do |attr, value| hashable.to_hash.each do |attr, value|
next unless self[attr].writable?
self[attr].value = value self[attr].value = value
end end
@ -378,9 +380,7 @@ class Post
# Ejecuta la acción de guardado en cada atributo. # Ejecuta la acción de guardado en cada atributo.
def save_attributes! def save_attributes!
attributes.select do |attr| attributes.map do |attr|
self[attr].writable?
end.map do |attr|
self[attr].save self[attr].save
end.all? end.all?
end end