Skip to content

undefined method '<<' for nil:NilClass #5354

@geeofree

Description

@geeofree

I have two models that has a has_one and belongs_to association with one another i.e

class User < ActiveRecord::Base
    has_one :hammer, dependent: :destroy
    accepts_nested_attributes_for :hammer, allow_destroy: true
end

class Hammer < ActiveRecord::Base
    belongs_to :user
end

After creating said models, I went on to make a form with these nested models following the documentation for it. However, I couldn't do so because I keep having this undefined method '<<' for nil:NilClass error that points to this particular code on the stacktrace

Snippet of the code I'm using that makes this happen:

form do |f|
    f.inputs 'User Information' do
        # user information inputs
    end

   f.inputs 'Hammer Information' do
       # below is where the error happens
       f.has_many :hammer do |h|
       end
   end
end

Is there anyway I can fix this?

Version of ActiveAdmin and Rails I'm currently using if it's needed:

  • activeadmin (1.0.0pre1)
  • activeadmin_addons (1.2.0)
  • Rails 4.2.6

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions