remove_avatar! leaves remove_avatar == true even after persisting the removal #1318

Closed
jtomaszewski opened this Issue Feb 11, 2014 · 2 comments

Comments

Projects
None yet
2 participants

Although the docs seem more clear now (#1230), there's one bug in the implementation:

object.update(avatar: some_file)
object.avatar.present? # => true

object.remove_avatar!
object.remove_avatar # => true
object.save!
object.avatar.present? # => false
object.remove_avatar # => still true. Why? Avatar has been already removed, #remove_avatar should be back to nil now.

object.update(avatar: some_file)
object.avatar.present? # => false :O propably because of the #remove_avatar == true

Thus, to update the file after removing it, I had to explicitly do this:

user.remove_avatar!
user.save!

user.remove_avatar = false # make sure #remove_avatar isn't true
user.update(avatar: new_file)

The problem is that I lost about ~1h on that - maybe we can fix it with something like after_save { remove_avatar = false } or should we note this on Wiki ?

@bensie bensie closed this in 88352b4 Feb 18, 2014

Thanks! 😄

Owner

bensie commented Feb 18, 2014

No problem, thanks for the detailed report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment