Update app/controllers/message_controller.rb

Add safety check on record operation