Skip to content

[Bug] After v3.1.0 using attributes name for attr_accessor in Form Objects breaks #96

@sebaherrera07

Description

@sebaherrera07

This may not be a bug that needs to be fixed, but it caused issues in production for us that were uncaught by our unit tests.

Bug report:

We have multiple form objects where we used something like this:

class RegistrationForm < YAAF::Form
  attr_accessor :attributes

  def initialize(attributes)
    super(attributes)
    @models = [user]
  end

  def user
    @user ||= User.new(attributes)
  end
end

Note that we use attributes as the name for the attr_accessor (in your docs example you use user_attributes.

This caused issues in production that raise errors like:

ActionView::Template::Error: undefined method 'fetch_value' for an instance of ActiveSupport::HashWithIndifferentAccess

I think we will proceed to rename all references to attributes for something like form_attributes and that should solve it. But opening a ticket to let you know about this issue.

I assume this was caused by this PR #93

  • Version of the repo: v3.1.0
  • Ruby and Rails Version: Ruby 3.4.8, Rails 8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions