attrio icon indicating copy to clipboard operation
attrio copied to clipboard

Attrio default doesn't work in ActiveRecord models

Open Sephi-Chan opened this issue 12 years ago • 0 comments

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.

Sephi-Chan avatar Jun 02 '13 10:06 Sephi-Chan