Skip to content

Instantly share code, notes, and snippets.

View willnet's full-sized avatar
👶
parenting

Shinichi Maeshima willnet

👶
parenting
View GitHub Profile
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"
# Activate the gem you are reporting the issue against.
require 'test/unit'
class Person
attr_checked :age do |v|
v >= 18
end
end
class TestCheckedAttribute < Test::Unit::TestCase
def setup
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", github: "rails/rails"
@willnet
willnet / create_association_test.rb
Created May 25, 2017 07:19
create_association method fails to save foreign_key
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", github: "rails/rails"
@willnet
willnet / inverse_of.rb
Created May 17, 2017 08:24
inverse_of が必須なケース
class User < ApplicationRecord
has_one :post
end
class Post < ApplicationRecord
belongs_to :fuga, class_name: 'User'
end
u = User.new
post = u.build_post
@willnet
willnet / tomcat6
Last active February 23, 2017 05:27 — forked from tcocca/tomcat6
tomcat init script for centos
#!/bin/bash
# description: Tomcat6 service
# processname: java
# chkconfig: - 99 1
# Source function library.
. /etc/init.d/functions
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
export TOMCAT_USER=solr
export CATALINA_HOME=/opt/tomcat6
require 'test/unit'
class Person
include CheckedAttributes
attr_checked :age do |v|
v >= 18
end
end
require 'test/unit'
class Person; end
class TestCheckedAttribute < Test::Unit::TestCase
def setup
add_checked_attribute(Person, :age) { |v| v >= 18 }
@bob = Person.new
end
@willnet
willnet / eval.rb
Last active December 14, 2016 04:45
require 'test/unit'
class Person; end
class TestCheckedAttribute < Test::Unit::TestCase
def setup
add_checked_attribute(Person, :age)
@bob = Person.new
end
@willnet
willnet / rescue.rb
Last active November 2, 2016 08:02
def hoge
raise
point = nil
rescue
p point #=> nil が出力される
end