Cocoon makes creating dynamic nested forms using jQuery easy. It works with formtastic, simple_form, and default forms.
Questions tagged [cocoon-gem]
499 questions
3
votes
2 answers
How to incorporate Cocoon links into buttons
In a rails project I am using the cocoon gem to create a nested form. In the provided example, the method link_to_remove_association is used, generating a link which deletes the current nested form when clicked.
This works fine as a link, but I wish…

user1618840
- 453
- 1
- 5
- 14
3
votes
0 answers
Rails 4 cocoon gem not working with js
I have trying to use cocoon dynamically nested form in my rails 4.1 + active-admin application. am not getting any errors but the add / remove links are not working.
when i checked in the browser with firebug the cocoon.js is not included with my…

Mani David
- 1,382
- 1
- 14
- 30
3
votes
0 answers
Rails - dynamically build nested object inside nested object partials (Cocoon)
Currently, I'm building a Medium-like blog service which users can add article parts(text, image, youtube...etc) that composite the article body.
Article model has many ArticlePart model and to create nested form dynamically, I'm using cocoon…

syncn
- 31
- 1
3
votes
1 answer
Can't get cocoon to work on Ruby on Rails 4
I've been battling trying to get this working for the last few hours, and I just can't for some reason. I've followed the steps almost exactly as indicated on the github repository link.
I created a new application using all of the following…

LewlSauce
- 5,326
- 8
- 44
- 91
3
votes
2 answers
Rails 4.0 & Cocoon: nested fields under fields_for don't appear in Edit
Hoping someone can suggest a fix here. I am fairly new to Rails, and exploring the changes in Rails 4.0. I built this simple recipe book app in Rails 4.0. I have a main model for recipes (name, cook_time, oven_temp, instructions, etc.). Because some…

user2670683
- 243
- 1
- 3
- 7
3
votes
1 answer
Rails 3.2 has_many :as polymorphic, Simple Form, simple_fields_for
Trying to save some images in my product form. I'm excpecting paremeters where I would have images_attributes being a part of "product". When I make parameters like that in the console and create a Product, the images actually save.
class Product <…

Johan Baaij
- 584
- 1
- 5
- 15
3
votes
1 answer
Get nested form field id number from cocoon
I am trying to get the following result:
Is there any dynamic tag I can add to…

Ole Henrik Skogstrøm
- 6,353
- 10
- 57
- 89
3
votes
1 answer
automatically adding child in nested form using cocoon
Suppose I have these models which I plan to add/delete on the same form:
class Survey < ActiveRecord::Base
has_many :questions
end
class Question < ActiveRecord::Base
belongs_to :survey
has_many :answers
end
class Answer <…

Henrique Pantarotto
- 404
- 3
- 10
3
votes
1 answer
No errors and no output for rails cocoon gem
I am working on a dynamically nested form using the cocoon gem. I have two models
class CrossTable < ActiveRecord::Base
attr_accessible :title, :table_name, :database, :folder_label_id, :foreign_fields_attributes
belongs_to :folder_label
…

Ben Fischer
- 6,382
- 2
- 17
- 22
2
votes
2 answers
Rails: Image preview inside a cocoon gem field
I have a simple form(product model) and I’m also using the cocoon gem for the nested fields(attachments model) that I have inside that form. When I create a product I use the cocoon gem for the nested fields in order to create attachments(images)…

Theopap
- 715
- 1
- 10
- 33
2
votes
1 answer
Rails: Cocoon gem add and remove fields
I'm using the cocoon gem and I'm trying to horizontally inline three nested fields and a remove button. I have achieved that but as you can see from the image I have attached, the width of the input-group(three inputs and the remove button) does not…

Dev
- 437
- 6
- 25
2
votes
1 answer
Rails: file nested fields, show the name of file selected on each field
I'm using the cocoon gem in order to add images with nested fields:
<%= f.simple_fields_for :attachments do |attachment| %>
<%= render 'products/attachment_fields', form: attachment %>
<% end %>

Theopap
- 715
- 1
- 10
- 33
2
votes
1 answer
Summernote editor not working with nested forms
I'm trying to use cocoon-gem and summernote-gem in my ruby-on-rails app.
This is my model:
class Dog < ApplicationRecord
has_many :pictures, as: :imageable, dependent: :destroy
accepts_nested_attributes_for :pictures, reject_if: :all_blank,…

Iris The Fox
- 43
- 2
- 7
2
votes
1 answer
Access all associations, including nested attributes, before save model
I have an Order, an Item and a Product model.
class Order < ApplicationRecord
has_many :items, dependent: :destroy, inverse_of: :order
end
class Item < ApplicationRecord
belongs_to :order
belongs_to :product
end
class Product <…

pzin
- 4,200
- 2
- 28
- 49
2
votes
1 answer
Update multiple checkboxes on association model through nested attributes with Cocoon gem in Rails
I found this answer here which should be able to solve my problem but turns out that answer is for a one to many association. Btw, i'm using Rails 5.2
In my many to many, I have a Task model which has_many test_methods through tasks_test_methods…

mayorsanmayor
- 2,870
- 4
- 24
- 44