Toggle

 

Learn how to easily toggle value of boolean attributes with #toggle method.

Code samples

# app/controllers/toggles_controller.rb

class TogglesController < ApplicationController
  def create
    @todo = Todo.find(params[:todo_id])
    @todo.toggle(:completed).save
  end
end

Links