class Place
include Mongoid::Document
field :current_position, type: Boolean, default: "false"
validates :user_id, presence: true
belongs_to :user, touch: true
end
class Place
include Mongoid::Document
field :current_position, type: Boolean, default: "false"
validates :user_id, presence: true
belongs_to :user, touch: true
after_save :update_position_for_other, if: :current_position_changed?
private
def update_position_for_other
Place.where(:id.ne => id, user_id: user_id).update_all(current_position: false) if current_position
end
end