Skip to content

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

Open

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

Activity

  1. santib commented on Feb 11, 2026

    @santib
    Contributor

    @andresg4 can you check it out? I guess that adding ActiveModel::Attributes caused this.

    @sebaherrera07 any suggestion on what would be the solution here? I'm thinking that the best option is adding a warning in our README that the name attributes is reserved by Rails?

  2. andresg4 commented on Feb 11, 2026

    @andresg4
    Contributor

    @santib yes it's caused by the addition of ActiveModel::Attributes. I already added a warning in the release notes, and planned to add one to the readme too. As far as I could check this would be the best option

  3. sebaherrera07 commented on Feb 11, 2026

    @sebaherrera07
    Author

    @andresg4 can you check it out? I guess that adding ActiveModel::Attributes caused this.

    @sebaherrera07 any suggestion on what would be the solution here? I'm thinking that the best option is adding a warning in our README that the name attributes is reserved by Rails?

    @santib Agree with you, I don't expect the gem to be modified, maybe just a warning in the README and the release notes for that version would be good.

  4. santib commented on Feb 11, 2026

    @santib
    Contributor

    thanks for letting us know 😄 🙌

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions