I'm a rails newbie, and I'm trying (failing) to add dynamic entries to my form. The cocoon gem doesn't work in any capacity for me.
This is my application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (http://ift.tt/1Hr2XzQ) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require cocoon
As you can see, it seems like it's being loaded correctly...? My rails version is 3.2.21
This is the relevant code from my form. I'm just trying to make the most basic thing:
<h2 align="center"> Workstation Analysis </h2>
<div id="workstations">
<%= f.fields_for :workstations do |workstation| %>
<%= render "shared/workstation_fields", f: workstation %>
<% end %>
<div class="links">
<% link_to_add_association "Add workstation", f, :workstations %>
</div>
</div>
My workstation_fields:
<div class="nested-fields">
<%= f.label :os, "Operating System" %>
<%= f.text_area :os %>
<%= f.check_box :_destroy %>
<% link_to_remove_association "remove workstation!!!!!!!!!!!!", f %>
</div>
The resulting error this throws is a file not found:
Missing template, responding with 404
Rendered common/error.html.erb within layouts/base
As a note, this is an error I get constantly whenever I do something wrong, completely (or seemingly completely) useless in determining the true problem.
Also, removing the line (in workstation_fields):
<% link_to_add_association "Add workstation", f, :workstations %>
Causes that error to go away -- but the corresponding "link_to_remove_association" doesn't show up anywhere on my webpage.
I'm just wondering if there's something obvious that I'm doing wrong. I'm following tutorials as best I can.
Thanks in advance for any help.
Aucun commentaire:
Enregistrer un commentaire