Hello, help to understand the bunch active_admin - formtastic is the controller:

ActiveAdmin.register Item do controller do def new @item = Item.new @color = @item.ItemColors.build end end 

and partial:

 <%= semantic_nested_form_for [@item, @color] do |f| %> <p>Category </p><%= f.input :category %></br> <%= f.input :title %> <%= f.input :photo1 %> <%= f.fields_for :ItemColors do |i| %> <%= i.select :DetailColor_id, collection => DetailColor.all %> <%= i.text_field :size %> <%= i.link_to_remove "remove" %> <% end %> <%= f.link_to_add "add", :ItemColors %> <% end %> 

when I try to create an Item, I get:

undefined method 'item_item_colors_path' for <#<Class:0x00000003de0348>:0x00000003de2f30>

Shrek: ok, I'll know

1101_debian: ItemColors - model

Model Item:

 has_many :DetailColors, :through => :ItemColors accepts_nested_attributes_for :ItemColors, :allow_destroy => true accepts_nested_attributes_for :DetailColors 

ItemColor Model:

 belongs_to :Item 

Model DetailColor:

 has_many :Items, :through => :ItemColor 
  • @Metallicolis the name of the question needs to be written more clearly, and not "Ruby on Rails", this is a copy-paste and the question becomes incomprehensible what it expects inside. - Artem
  • one
    What is ItemColors? Why with a capital letter? - AlexDenisov
  • ItemColors intermediate model between Item and DetailColor - Metallicolis

1 answer 1

Rails expects you to follow certain naming conventions. Rename the fields as usual, and it may very well be that the error disappears by itself. Attribute names in lower_case

In addition, show rake routes to make it clearer what you have there. Show the html-code that generates semantic_nested_form_for .

  • Thanks for the answer. In general, I have already solved this problem by rewriting the first line in the partial: <% = semantic_nested_form_for @item,: url => admin_items_path do | f | %>. Everything is added as it should. But now another problem is that I can’t understand how to index a page of values ​​from related forms, namely ItemColor and size I try this: column: item do | itemcolor | itemcolor end I get an item field with values ​​like: # <Category: 0x000000081afa60> - Metallicolis