Bench with unassigned attributes


#1

I’m not quite sure what a saved record with unassigned attributes means.

user = User.create!(name: 'abcde', long_name: 'abcdefgh')
user.reload
user.name = 'abcde'
user.long_name = 'new name'
user.save

Perhaps something like this?


#2

I guess it’s default value from migration. i.e. AR skips setting the value and padded by PG later on.


#3

Is there an example? I still don’t quite understand what it means :slight_smile:


#4

Suppose your example:

Migration:

create_table :users do |t|
  t.text :name, null: false
  t.text :long_name, default: 'long'
  t.timestamps
end

long_name is not assigned in that case:

user = User.new(name: 'abcde')
user.save