Skip to content

Default values aren't assigned when initialize method is present. #373

Description

@prasadsurase

I am using rails 5.0.2 with virtus 1.0.5. I have a form defined as below

class MyForm
  include Virtus.model

  attribute :age, Integer, default: 0
  attribute :birthday, DateTime, default: :some_date
  attribute :salutation, String, default: 'Mr.'

  def initialize
  end

  private

  def some_date
    Date.today - 3.years
  end
end

If the initialize method is removed, the default values are present when an instance of MyForm is created. The values are absent if the initialize is present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions