-
Notifications
You must be signed in to change notification settings - Fork 129
Closed
Labels
Description
Steps to reproduce
$ rails _8.0.1_ new hoge_app
$ cd hoge_app
$ rails g model vehicle type:string color:string price:integer release_date:datetime
$ rails g model car --parent=Vehicle
$ rails db:migrate# Gemfile
source "https://rubygems.org"
gem "rails", "~> 8.0.1"
gem "default_value_for"
# app/models/vehicle.rb
class Vehicle < ApplicationRecord
default_value_for :color, "black"
end
# app/models/car.rb
class Car < Vehicle
default_value_for :price, 100
default_value_for :release_date, DateTime.now
end$ bundle install
$ rails r 'p Car.new'
#<Car id: nil, type: "Car", color: "black", price: nil, release_date: "2024-12-26 04:30:36.002660000 +0000", created_at: nil, updated_at: nil>Expected behavior
$ rails r 'p Car.new'
#<Car id: nil, type: "Car", color: "black", price: 100, release_date: "2024-12-26 04:30:36.002660000 +0000", created_at: nil, updated_at: nil>Actual behavior
- price is set to
nil
System configuration
Rails version: 8.0.1
Ruby version: 3.3.5
DefaultValueFor version: 4.1.0
Additional information
It seems to be caused by the modification of class_attribute method in Rails 8.0.1.
rails/rails#53640