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
# Schemafileから | |
# require_relative './lib/ridgepole_hashed_index_name' | |
# して使う | |
module RidgepoleHashedIndexName | |
def index_name(table_name, options) | |
if options.is_a?(Hash) && options[:column] | |
identifier = super | |
hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10) | |
"index_rails_#{hashed_identifier}" |
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
# frozen_string_literal: true | |
dowsing = Module.new do | |
def execute(sql, *) | |
source_location = query_source_location(caller.lazy) | |
sql = "#{sql} /* #{source_location} */" if source_location | |
super | |
end | |
private |
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
# frozen_string_literal: true | |
RSpec.describe 'ActiveRecord i18n' do | |
let(:table_names) { ActiveRecord::Base.connection.tables } | |
let(:models) do | |
table_names.map do |table_name| | |
table_to_model(table_name) | |
rescue NameError | |
nil |
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
# frozen_string_literal: true | |
RSpec.describe 'rake db:seed' do | |
it 'works fine' do | |
expect { load('db/seeds.rb') }.to_not raise_error | |
end | |
end |
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
# frozen_string_literal: true | |
RSpec.describe 'ActiveRecord duplicated indexes' do | |
let(:connection) do | |
ActiveRecord::Base.connection | |
end | |
it 'is not found' do | |
tables = connection.tables | |
duplicated_indexes = {} |
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
# frozen_string_literal: true | |
RSpec.describe 'ActiveRecord foreign key' do | |
let(:connection) { ActiveRecord::Base.connection } | |
let(:tables) { connection.tables } | |
def foreign_key_exists?(reflection, foreign_keys) | |
to_table_name = reflection.klass.table_name | |
reflection.foreign_key |
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
https://github.com/kufu/activerecord-bitemporal/pull/70/files#diff-77aac43b146505859dd74b1fd3e151c0e94174f5abc85475fe1dfba10a5c64bfL330 | |
git clone https://github.com/kufu/activerecord-bitemporal | |
hub checkout https://github.com/kufu/activerecord-bitemporal/pull/70 | |
# L330をObjectに戻す | |
vi lib/activerecord-bitemporal/bitemporal.rb | |
rbenv local 3.0.0 | |
bundle i --path .bundle |
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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", '~> 6.1.0' |
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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", '~> 6.0.0' |
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
module ActiveModelAttributesInspector | |
# @return [String] | |
def inspect | |
values = attributes.map { |key, value| "#{key}: #{value.inspect}" }.join(', ') | |
%(<#{self.class.name} #{values}>) | |
end | |
# @param pp [PP] | |
# | |
# @return [void] |