- 現時点(2024/08/30)でRails7.2.1がリリースされています
- Ruby on Rails 7.2 Release Notes — Ruby on Rails Guides にメジャーフィーチャーが書かれている
- マイナーフィーチャーはよくわからないので、個人的に気になったマイナーフィーチャをまとめています
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" | |
gem "rails", "7.0.8.4" | |
# If you want to test against edge Rails replace the previous line with this: | |
# gem "rails", github: "rails/rails", branch: "main" |
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
require 'set' | |
class InspectAssociations | |
def self.call(model) | |
new.call(model) | |
end | |
def call(model) | |
return if set.include?(model) | |
set.add(model) |
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
require 'ferrum' | |
require 'base64' | |
browser = Ferrum::Browser.new(logger: File.open('/tmp/hoge.log', 'w')) | |
Dir.mktmpdir do |dir| | |
browser.on('Page.screencastFrame') do |params, index, total| | |
File.open("#{dir}/#{Time.now.strftime('%Y%m%d%H%M%S%L.jpeg')}", 'w') do |f| | |
f.write(Base64.decode64(params['data'])) | |
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
ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |model| | |
string_or_text_columns = model.columns.select { |column| column.type == :string || column.type == :text } | |
columns_with_maximum_length_validation = model.validators.select {|v| v.is_a? ActiveRecord::Validations::LengthValidator }.select {|v| v.options[:maximum] || v.options[:within] }.map(&:attributes).flatten.uniq | |
string_or_text_columns.each do |column| | |
if columns_with_maximum_length_validation.include?(column.name.to_sym) | |
puts "#{model.name}##{column.name} is OK" | |
else | |
puts "#{model.name}##{column.name} is NG" | |
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
// chromeを利用して、ユーザ一覧を表示しつつconsoleで↓を実行すると、現在の参加者からランダムで一人表示することができます | |
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word)=> !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep|domain_disabled/)) | |
const names_set = new Set(names_array) | |
const names_uniq_array = Array.from(names_set) | |
names_uniq_array[Math.floor(Math.random() * names_uniq_array.length)] |
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
source 'https://rubygems.org' | |
platforms :jruby do | |
gem 'railties' | |
end | |
group :test do | |
gem 'railties' | |
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
class ApplicationRecord < ActiveRecord::Base | |
@ar_initialize_counter = Hash.new(0) | |
@ar_find_counter = Hash.new(0) | |
after_initialize :count_initialize | |
def count_initialize | |
return unless ApplicationRecord.enable_counter? | |
gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } | |
caller_in_app = caller.find { |file_and_lineno| file_and_lineno !~ gems_paths} |
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
{ | |
"mode": "development", | |
"output": { | |
"filename": "js/[name]-[contenthash].js", | |
"chunkFilename": "js/[name]-[contenthash].chunk.js", | |
"hotUpdateChunkFilename": "js/[id]-[hash].hot-update.js", | |
"path": "/Users/willnet/tmp/webpacker5/public/packs", | |
"publicPath": "/packs/" | |
}, | |
"resolve": { |
NewerOlder