cocoon-gem

Can you the coccon gem without a direct nested association?

て烟熏妆下的殇ゞ 提交于 2020-01-06 06:54:24
问题 I have to convert my form to not using nested association. In other words, instead of <%= link_to_add_association f, :contacts, class: 'btn btn-primary', partial: 'projects/contact_fields', data: { association_insertion_node: '.contact_fields', association_insertion_method: :append } do %> <i class="fas fa-plus"></i> <% end %> <%= f.fields_for :contacts do |contact| %> <%= render 'projects/contact_fields', f: contact %> <% end %> I would like to be able to just pass in a string to be used as

Rails materialize-sass form with autocomplete and cocoon gem nested resource

不想你离开。 提交于 2019-12-25 00:38:05
问题 I am using materialize-sass gem on a form. Using autocomplete feature to get Vendor names. other fields on the form are item names and quantity which are a nested resource. For this I am using cocoon gem For some reason the very first time the page loads, all seems to work fine. But adding more fields does not seem to be working. I tried using drop down select and that does not show the list of items. I replaced it with another autocomplete and the main field does show however the auto

Rails cocoon-gem double nested forms “undefined method”

痴心易碎 提交于 2019-12-24 14:49:55
问题 I'm using the cocoon gem in my rails app and trying to double-nest forms. The first "link_to_add_association" adds the valve_fields partial which contains another "link_to_add_association" it gives this error: ActionView::Template::Error (undefined method `fetch_value' for nil:NilClass): 21: .line_items 22: =f.simple_fields_for :line_items do |line_item| 23: =render 'line_item_fields', :f => line_item 24: //error line// =link_to_add_association "add line", f, :line_items I haven't done

Rails 5, Cocoon Gem - nested form inside nested form

孤街浪徒 提交于 2019-12-24 06:37:37
问题 I am trying to use cocoon gem to build nested forms. I have models for Organisation, Package::Bip and Tenor. The associations are: Organisation has_many :bips, as: :ipable, class_name: Package::Bip accepts_nested_attributes_for :bips, reject_if: :all_blank, allow_destroy: true Package::Bip (polymorphic) belongs_to :ipable, :polymorphic => true, optional: true, inverse_of: :bip has_one :tenor, as: :tenor accepts_nested_attributes_for :tenor, reject_if: :all_blank, allow_destroy: true Tenor

Ruby on Rails: Selectize.js with Cocoon

好久不见. 提交于 2019-12-24 06:08:50
问题 I'm trying to make a form in Ruby on Rails to select parts of the construction. New fields (part entries - the joining table) are added by Cocoon gem. Everything works fine but when trying to edit saved constructions Selectize cannot read its current parts' fields. Here is my _part_fields.html.erb: <li class="control-group nested-fields"> <div class="controls"> <%= f.input :quantity %> <%= f.select :part_id, options_from_collection_for_select(Thing.all, :id, :name), {:prompt => "Select or

Ruby on Rails: Selectize.js with Cocoon

二次信任 提交于 2019-12-24 06:07:57
问题 I'm trying to make a form in Ruby on Rails to select parts of the construction. New fields (part entries - the joining table) are added by Cocoon gem. Everything works fine but when trying to edit saved constructions Selectize cannot read its current parts' fields. Here is my _part_fields.html.erb: <li class="control-group nested-fields"> <div class="controls"> <%= f.input :quantity %> <%= f.select :part_id, options_from_collection_for_select(Thing.all, :id, :name), {:prompt => "Select or

Can't get cocoon to work on Ruby on Rails 4

不打扰是莪最后的温柔 提交于 2019-12-23 17:55:26
问题 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 steps: # rails new demo_app # cd demo_app/ +++ added gem 'cocoon' to the Gemfile +++ added //= require cocoon to the application.js file # rails g scaffold Project name:string description:string # rails g model Task description:string done:boolean project

Update field inside fields_for with Cocoon and Jquery

眉间皱痕 提交于 2019-12-23 04:11:40
问题 I would like to set the value of field inside fields_for with Cocoon gem using Jquery. I am using change event on jquery. _form <%= form_for(@invoice) do |f| %> <div class="field"> <%= f.label :total_order %><br> <%= f.number_field :total_order %> <%= f.object_id %> </div> <div id="items"> <%= f.fields_for :items do |i| %> <%= render 'item_fields', :f => i %> <% end %> <div class="links"> <%= link_to_add_association '+ produk', f, :items %> </div> </div> <div class="actions"> <%= f.submit %>

Change only the image inside same div when option from dropdown is chosen

血红的双手。 提交于 2019-12-23 03:12:33
问题 I have a nested form where you can add new bracelets to your order. For each bracelet you can choose a color, and next to the select (dropdown) where you choose the color there is an image with the bracelet on that color. The problem is this: When I add a new nested-fields div (form for new bracelet), when I select a color in the dropdown the image next to it doesn't change. Also, when I select a color in the dropdown for the first bracelet, the images for all the bracelets change to that

Cocoon and has_one association

人盡茶涼 提交于 2019-12-22 08:23:43
问题 I have searched on stack overflow and google to no avail. I have a person who has_one next_of_kin I can create a person with a nested form (with cocoon) and it saves perfectly. For some reason when I then go to the edit page it deletes the associated next_of_kin record. It renders the fields populated with the record's data, but the actual record in the database gets deleted. My form .full-width-row = simple_form_for @person, url: {action: action}, wrapper: 'two_column_form' do |f| .columns