Created
August 6, 2017 12:00
-
-
Save klappradla/80eeda7538fd5a924ef83817156b8ffe to your computer and use it in GitHub Desktop.
Single file rails app to illustrate acceptance only validations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails" | |
gem "pg" | |
gem "pry" | |
end | |
require "active_record" | |
ActiveRecord::Base.establish_connection(adapter: "postgresql", database: "validation_example") | |
ActiveRecord::Schema.define do | |
create_table :users, force: true do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
class User < ActiveRecord::Base | |
validates_acceptance_of :terms_of_service | |
end | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this: