Home > Net >  Accessing fields_for object in Rails undefined method
Accessing fields_for object in Rails undefined method

Time:11-08

I'm trying to access my fields_for object in order to access its properties with no luck:

  <%= f.fields_for :items do |item| %>
    <%= item.object.id %>
  <% end %>

Output:

undefined local variable or method `item' for #<#<Class:0x0000000106aa5eb8>:0x000000012d4d6038>

Any ideas?

CodePudding user response:

Feels like you are missing the instance here?

[...]
<%= f.fields_for :items, @some_instance.items do |item| %>
[...]

at least thats what a glance at the docs might suggest

  • Related