Quantcast
Viewing latest article 10
Browse Latest Browse All 42

Unable to see partial when using cocoon gem

I have installed cocoon and added all of the necessary changes according to the examples outlined here: https://github.com/nathanvda/cocoon/wiki/ERB-examples

Yet for some reason I am not able to see anything inside my partial.

views/order_items/_order_item_fields.html.erb:

<div class="nested-fields"><div class="field"><%= f.label :material %>    TEST</div><%= link_to_remove_association "remove order_item", f %></div>

views/orders/new.html.erb:

<div class="container text-center mt-4"><%= form_for @order do |f| %><div class="container"><div class="row"><h2>New Order</h2></div></div><div id="order_items"><%= f.fields_for :order_items do |order_item| %><%= render "order_items/order_item_fields", f: order_item %><% end %><div class="links"><%= link_to_add_association "add order_item", f, :order_items %></div></div><div class="actions"><%= f.submit %></div><% end %></div>

Order.rb:

class Order < ApplicationRecord  belongs_to :user, optional: true  has_many :order_items  accepts_nested_attributes_for :order_items, reject_if: :all_blank, allow_destroy: trueend

I am also getting a Missing Template error:Missing partial orders/_order_item_fields, application/_order_item_fields with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}.

I believe if I'm trying to render the partial from another view folder, that adding the folder before the partial name should work: <%= render "order_items/order_item_fields", f: order_item %>

If I move _order_item_fields.html.erb from views/order_items into my views/orders directory, the page will render, but I still can't see anything inside the order_item_fields partial.


Viewing latest article 10
Browse Latest Browse All 42

Trending Articles