Go back Ruby & Ruby on Rails tricks

valodate checkbox checked (e.g terms of services accepted) validates_ acceptance



class User < ApplicationRecord
  validates :terms_of_service, acceptance: {message: "Please agree with T&C"}, on: :create

  attr :terms_of_service
end

<%= form.checkbox :terms_of_service %>