cocoon-gem

rspec doesn't see fields dynamically added or removed by cocoon in nested form

断了今生、忘了曾经 提交于 2019-12-08 04:06:05
问题 In my application in Rails 4, I use Cocoon to have nested forms. It works well in the browser, but I want to add some tests with rspec. If I make a click_link("add") (or 'remove') in my test, rspec doesn't see any modification (I print page.body before and after). I also tried with a sleep(10) but it's the same. How could I test if the action (add or remove a nested form) works well ? Thanks EDIT: The scenario to test : scenario "nested form" do user_sign_in contact = FactoryGirl.create(

rspec doesn't see fields dynamically added or removed by cocoon in nested form

微笑、不失礼 提交于 2019-12-06 21:13:35
In my application in Rails 4, I use Cocoon to have nested forms. It works well in the browser, but I want to add some tests with rspec. If I make a click_link("add") (or 'remove') in my test, rspec doesn't see any modification (I print page.body before and after). I also tried with a sleep(10) but it's the same. How could I test if the action (add or remove a nested form) works well ? Thanks EDIT: The scenario to test : scenario "nested form" do user_sign_in contact = FactoryGirl.create(:contact) visit new_message_path expect(page).to have_text("New message") puts page.html click_link('Add an

Rails 4 & cocoon gem: Cannot add 3rd level child to dynamically added 2nd level child

大兔子大兔子 提交于 2019-12-06 13:00:28
问题 I am currently using the cocoon gem to handle my nested form along with bootstrap/simple_form. My models are laid out like this: A Contact has_many goals A Goal has_many tasks A Task has_one reminder (not yet implemented, this is next once I resolve this issue) My form is laid out with the Goal fields being built correctly, and I can add/remove tasks to my first Goal without a problem. However, when I dynamically add another Goal (regardless if it's in the new or edit action), I cannot add

Rails cocoon nested form only receiving one first nested attribute

社会主义新天地 提交于 2019-12-06 05:32:47
I am trying to build a form with nested resources in my rails 4 app. I am using the cocoon gem. Each step will have substeps, and I'd like to allow the user to add as many substeps to the form and he/she would like. Step.rb class Step < ActiveRecord::Base has_many :substeps accepts_nested_attributes_for :substeps Substep.rb class Substep < ActiveRecord::Base belongs_to :step form code <%= form_for Step.new, :url => steps_path do |f| %> <%= text_field(:step, :title, :value => '', class: 'fly-input input_info', placeholder: 'Process Title', id: 'step_form_title') %> <%= text_field(:step,

Cocoon and has_one association

喜欢而已 提交于 2019-12-05 13:14:02
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.medium-4 h4 = heading .columns.medium-8 = f.button :submit, 'Save', class: 'right button tiny radius'

Testing fields added dynamically by cocoon using rspec and capybara

…衆ロ難τιáo~ 提交于 2019-12-03 20:52:18
问题 I was wondering whether anybody tests fields that were dynamically added by cocoon? It's a great little time saver but all of the fields that are added dynamically have really long numerics added to the ID and name. This means that I have to skip testing that requires more than one (set of) field(s) on the page. 回答1: Maybe using Capybara finders all, first and the selector input. Something like this: visit new_resource_path click_link "Add a Nested Resource" first("input[name='nested_resource

nested_form/cocoon: is it okay to use table rows for nested fields?

℡╲_俬逩灬. 提交于 2019-12-03 09:27:26
问题 I normally don't use tables for forms, but when having a nested form (when using nested_form or cocoon gem), is it okay then to put each set of form elements inside a table row? To me, this seems pretty intuitive: every row in the table represents an object. But neither the nested_form nor the cocoon gem add tables in their examples by default, so I wonder whether using forms isn't the best way to go? 回答1: Yes. If you are inputting tabular data then you should use a table. I haven't tested

Rails - Dynamically build deeply nested objects (Cocoon / nested_form)

五迷三道 提交于 2019-12-03 05:46:21
问题 I currently have a complex form with deep nesting, and I am using the Cocoon gem to dynamically add sections as required (e.g. if a user wants to add another vehicle to the sale form). Code looks like this: <%= sale.fields_for :sale_vehicles do |sale_vehicles_builder| %> <%= render :partial => "sale_vehicles/form", :locals => {:f => sale_vehicles_builder, :form_actions_visible => false} %> <% end -%> <div class="add-field-links"> <%= link_to_add_association '<i></i> Add Vehicle'.html_safe,

Rails - Dynamically build deeply nested objects (Cocoon / nested_form)

独自空忆成欢 提交于 2019-12-02 18:13:56
I currently have a complex form with deep nesting, and I am using the Cocoon gem to dynamically add sections as required (e.g. if a user wants to add another vehicle to the sale form). Code looks like this: <%= sale.fields_for :sale_vehicles do |sale_vehicles_builder| %> <%= render :partial => "sale_vehicles/form", :locals => {:f => sale_vehicles_builder, :form_actions_visible => false} %> <% end -%> <div class="add-field-links"> <%= link_to_add_association '<i></i> Add Vehicle'.html_safe, sale, :sale_vehicles, :partial => 'sale_vehicles/form', :render_options => {:locals => {:form_actions

No errors and no output for rails cocoon gem

喜夏-厌秋 提交于 2019-12-02 02:18:36
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 has_many :foreign_fields accepts_nested_attributes_for :foreign_fields validates :title, :table_name, :database, :folder_label_id, presence: true end class ForeignField < ActiveRecord::Base attr_accessible :cross_table_id, :column_name, :description belongs_to :cross_table has_many :filter_sets end I have cocoon and jquery-rails in the gemfile I added //