497
questions
0
votes
0
answers
39
views
Console Syntax Error after installing and then removing Rails gem cocoon
I installed a rails gem called cocoon by nathanvda using these instructions
It did not work for me so I uninstalled it by deleting the line from the gem file and running bundle install.
However, now ...
0
votes
0
answers
39
views
How to update multiple checkboxes values on join table through nested attributes with Cocoon gem in Rails
I did some research and found this(Update multiple checkboxes on association model through nested attributes with Cocoon gem in Rails) but my case is a bit different i assume.
Suppose I have 3 models: ...
0
votes
1
answer
58
views
Nested forms not appending to params nested attributes (COCOON RAILS)
I'm making a nested form with Cocoon gem for my Campaign model, in order to add items by using link_to_add_association to add new item rows. My associations are working correctly.
I can see in my ...
0
votes
0
answers
238
views
cocoon gem double nested form not working
_form.html.erb
<%= form_for @business, remote: true, :html => { :id => "newbusinessForm" } do |f|%>
...
<%= f.fields_for LifePage.new do |life_page| %>
<% ...
0
votes
1
answer
330
views
Rails Nested Fields With Cocoon - link_to_add_association is Deleting Records
I'm using nested fields and accept nested attributes with a 3 level nested relationship. The 3rd level (I don't think it matters that it's third level) relationship gets deleted when editing the ...
1
vote
2
answers
3k
views
Cocoon gem issue in Rails 7
I want to implement nested form using cocoon gem.
There is no error but when I click on the item link to edit and trigger it, nothing works. However, the URL chnages from http://127.0.0.1:3000/...
0
votes
1
answer
63
views
Simple_fields_for with cocoon not rendering
I have a one-to-many association in Ruby on Rails:
class Booking < ActiveRecord::Base
has_many :rides
accepts_nested_attributes_for :rides, allow_destroy: true
end
### and ###
class Ride < ...
1
vote
1
answer
154
views
How to write the cocoon delete link with an icon
I'm using rails 5, gem 'cocoon' and 'twitter-bootstrap-rails' v.4.0.0.
I want to exchange below "Delete" for link_to_remove_association with a bootstrap trash icon.
<%= ...
0
votes
1
answer
201
views
Cocoon Gem is rendering form twice
I am using Cocoon Gem to build dynamic form. Every thing is working fine. I am able to add new record, delete the records. But my form and submit button is getting displayed twice. I have checked ...
0
votes
1
answer
355
views
overwrite the create method of the model
I am using the cocoon gem for nested records and because the form will be submitted by ajax and must remain in the form after submitting the data for creation, I need to modify the create method of ...
0
votes
1
answer
330
views
Add clone button on each nested child object with Cocoon and Rails
I have a parent, which I can add multiple children and I would like to add a clone button with cocoon in each child.
Following the next solution I have made this code:
These are the models:
class ...
0
votes
1
answer
221
views
Cocoon callbacks aren't firing on Rails6
My problem is similar to the one described in https://github.com/nathanvda/cocoon/issues/399.
Adding and removing nested fields works, but callbacks don't fire.
application.js:
import Rails from "...
0
votes
1
answer
284
views
Rails 5: How to handle serialized string array in simple_form?
As title, I have a serialized string column in the model:
class Product < ApplicationRecord
serialize :ingredient_fields, Array
end
The ingrdient_field has many strings, but store in one column ...
0
votes
1
answer
106
views
How to integrate a copy button to a form that is created using cocoon gem
There are FundApplication and ExpenseRequest, FundApplication has_many expense_requests.
Pressing the 'Add Expense' Button will add expense requests and is working fine. Now my client asks me to ...
0
votes
0
answers
50
views
What the buildpack should i add for the nested attributes to make it work in heroku?
What the buildpack should i add for the link_to_add_association to make it work in heroku?
for some reason the gem cocoon works locally but not working in heroku
Someone mention to add buildpack to my ...
0
votes
0
answers
123
views
gem cocoon work locally but not in production
I did alot of research to make this work. but nothing solved mine
link_to_add_association not working in heroku
gem "cocoon"
<%= form_for(resource, as: resource_name, url: ...
1
vote
1
answer
283
views
execute javascript function after adding fields with cocoon
I'm developing my application in rails, in my app I'm extracting a form in a modal window through ajax, the form has a cocoon button to add nested records, the problem comes when adding new nested ...
0
votes
1
answer
125
views
# added to URL when clicking link_to_add OR link_to_remove_association
I'm using Rails 6 and I'm trying to make nested_fields work. I'm using Cocoon. There is no JS error, JQuery is correctly loaded. The nested_form loads the nested data correctly, but I'm unable to add ...
0
votes
1
answer
1k
views
link_to_add_association and link_to_remove_association Nested form Cocoon gem
his is the first time I am using cocoon gem so I am not sure how to use it properly,I am not getting error but the link_to_add_association is not working." link_to_remove_association" gives &...
0
votes
0
answers
130
views
how to execute function after cocoon add the record?
I'm using the cocoon gem in my rails project, and I have two "link_to_add_association", but I need that depending on which link_to is pressed to do a certain function, link_to with id "...
0
votes
2
answers
50
views
How do I call Pickadate javascript again after I click on "Add Item" from Cocoon gem in nested form?
I have a form to create billing statements (parent) that accepts nested attributes for billing statement items (children).
Billing statement items has a due date attribute which I have wrapped a date ...
0
votes
2
answers
2k
views
How to create an object if it does not exist in a nested form in Rails 6?
I need to create a Training, then add Attendances with nested form fields (cocoon) in a Rails 6 app. Here is the situation:
The models are the following:
Training model
class Training < ...
0
votes
1
answer
360
views
Nested form with cocoon rails duplicates child items when editing
The nested form works great when creating new records. However when I edit the record, it creates duplicate child items even if I do not mean to add new items.
How do I prevent it from creating new ...
1
vote
3
answers
560
views
Simple form with has_many through and join table
I have models: Product, Parts and ProductParts
product.rb
class Product < ApplicationRecord
has_many :product_parts
has_many :parts, through: :product_parts
accepts_nested_attributes_for :...
1
vote
1
answer
551
views
Automatically adding nested child partials on link_to_add_association click using Cocoon
I have a form with 4 nested levels that I'm using to dynamically add items, shipments, and calculate costs. I have the form set up to where I can add/remove everything I need with button clicks. ...
0
votes
1
answer
464
views
using data-action with cocoon:after-insert
I am converting some older JS into stimulus.
$(document).on('cocoon:after-insert', function(e, element) {
$some_inputs.change(updateMethodName)
})
The cocoon add partial looks like
= ...
1
vote
2
answers
249
views
has_many through and values on the join table with Cocoon
I can't seem to get my forms working correctly despite following many guides, tutorials and examples.
I have a model location.rb:
class Location < ActiveRecord::Base
has_many :location_gateways
...
1
vote
0
answers
287
views
ActiveRecord::AssociationTypeMismatch when updating form
I have a form with cocoon including nesting fields and I get the following when updating
here is my schema
create_table "tournament_standings", force: :cascade do |t|
t.integer "...
0
votes
2
answers
146
views
jQuery trigger all instances on a nested form rails cocoon
I have a form with the following which are nested fields using cacoon
I have default fields and a conditional to show more fields if an option is selected ie. Rocket League like so
However, as you ...
0
votes
1
answer
798
views
Render fields based on category select rails
So I have the following form using cocoon nesting some fields in a partial
<%= form_with(model: tournament, local: true, class: "mt-8 md:mt-12") do |f| %>
<% if tournament.errors.any? %>...
0
votes
1
answer
273
views
Rails cocoon: Nested fields disappear after I submit the form
I have the following three models and associations:
class ParentProduct < ApplicationRecord
has_many :child_products
accepts_nested_attributes_for :child_products, allow_destroy: true
...
1
vote
0
answers
107
views
Changes aren't being saved by the edit page - Cocoon Gem
Pardon me if my language isn't correct, I'm relatively new to Rails and Ruby.
I'm using Cocoon to select from a list of currently existing options in a nested model, but the options I choose never ...
0
votes
1
answer
595
views
Rails: Nested fields inside a nested form
I have the following three models and associations:
class ParentProduct < ApplicationRecord
has_many :child_products
accepts_nested_attributes_for :child_products, allow_destroy: true
...
0
votes
1
answer
170
views
Rails 5 inverse_of join table doesn't want to work with deeply nested Cocoon fields
I am using Ruby 2.6.5 and Rails 5.2.3. I have a form with double nested objects with Cocoon. The form is for Preorders. A Preorder can have many Dancers. Dancers can have many and belong to many ...
2
votes
2
answers
402
views
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 ...
0
votes
1
answer
265
views
Rails 6 nested form cocoon won't save sub-objects
I am trying to implement a nested form for a Book object which can have several BookAuthor objects. I have followed this tutorial to do this with the Cocoon gem in Rails 6, however it does not work. ...
0
votes
2
answers
642
views
Rails cocoon nested form: webpacker can't find cocoon
I'm using the cocoon gem to build nested forms as I would like the user to fill in as many 'sub_step' as he wants in a 'main_step' form.
Here is my code:
MainStep model
class MainStep < ...
0
votes
0
answers
525
views
Cocoon not adding/deleting fields in nested form
I'm building a form in where I can add/delete doses for a cocktail. I'm using cocoon gem but when clicking "add/remove dose" nothing happens in the browser, when clicking "add" no new fields appear ...
1
vote
0
answers
243
views
Rails + simple_form nested object with cocoon. How to sort objects with errors and display it first
I have a join table with simple form. With nested has_many :through association. I add multiply objects with cocoon gem.
It renders like:
<%= v.simple_fields_for :document_place_rooms do |vf| %&...
0
votes
0
answers
63
views
Nested formed by cocoon cannot be saved
Problem
I'm coding user's profile page on Rails.
I added a gem "language-select" for users to choose a language which they're learning. And users might learn several languages, so I added ...
0
votes
0
answers
141
views
Gem Cocoon not rendering anything
I'm using Rails 6.0.2.2, Foundation, and wanted to do some nested forms using Cocoon. Here are my models:
class Adventure < ApplicationRecord
alias_attribute :pcs, :player_characters
has_many ...
0
votes
1
answer
508
views
Rails: array column inside nested attribute params wrong number of arguments (given 0, expected 1..2)
I don't know if it's relevant, but I'm using the Cocoon Gem.
My main resource that is saving is a Property.
I have nested attributed for this property called property_unit_attributes
params.require(...
1
vote
1
answer
701
views
Rails custom validate method
I'm using the ancestry gem in order to create subcategories. After that when I create an item (item model) I use the following group select in order to associate the item with the subcategories it ...
2
votes
1
answer
830
views
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-...
6
votes
1
answer
714
views
Rails cocoon gem: populate multiple fields
I'm using the cocoon gem on my rails app and I have two nested fields inside a form (categories, subcategories). Initially I'm showing the first one only and the second one is hidden. Each time the ...
1
vote
0
answers
35
views
How do I save a double nested many to many association?
I have three models :request, :access_account and :permission.
class Request < ApplicationRecord
has_many :access_account_requests
has_many :access_accounts, through: :...
0
votes
0
answers
197
views
Using Globalize gem in nested form using Cocoon gem
I used both the Globalize gem as well as the Cocoon gem before and everything worked out fine. However, when I try to use Globalize within a cocoon nested form, I get an error message I don't know how ...
-1
votes
1
answer
370
views
Nested form doesn't show up on page
I'm trying to build a nested form, but I can't get it to work. I'm using rails 5.2, devise and wicked wizard.
I have tried to use the cocoon gem, but without luck. The problem is, that the nested form ...
1
vote
1
answer
110
views
Cocoon Item field not posting values to database
I have a genearted lineItem field using Cocoon gem, am having issues trying to save the line items field values,and when I inspect the elements the add_item button wasn't triggering a unique ID for ...
1
vote
1
answer
557
views
dynamically generated nested form with cocoon rails
I have a nested form with cocoon, but am having an issue trying to calculate my total price from the JavaScript. And when I check my view source page the generated attribute from the fields have no ...