What does it mean when the bang method is in front? What is this shorthand for?
!post.save
What does it mean when the bang method is in front? What is this shorthand for?
!post.save
It's a negation. In your example it means to NOT the result of post.save.
if:
post.save => true
!post.save => false
otherwise:
post.save => false
!post.save => true
It is equivalent to
not post.save
Usually used in if clauses, like:
if !post.save #if the post could not be saved for some reason
puts 'could not save post!'
end
It's because the function save from ActiveResource::Base returns true if the POST request succeeded and false if it didn't. Read here for some more information about the function.