attrio
attrio copied to clipboard
Attrio default doesn't work in ActiveRecord models
With the following code:
class Format < ActiveRecord::Base
include Attrio
define_attributes(inspect: false) do
attr :teams_count, Integer, default: 2
end
end
The following test fails:
class FormatTest < ActiveSupport::TestCase
test "Teams count of a format should default to 2" do
Format.create(name: 'Foo')
assert_equal 2, Format.first.teams_count
end
end
The saved value of teams_count is nil.