cocoon-gem

Dynamically Auto Save Rails Form using Ajax is failing at some Point

 ̄綄美尐妖づ 提交于 2019-12-11 14:59:05
问题 I am basic developer of Rails, Not some professional ! I am trying to auto save the rails form after some interval using ajax Dynamically. Actually The real need is that when the first time ajax function executes it inserts the object in the database and afterwards it updates that object. I tried this approach on simple object without any Associations and it works, but right now The requirement is quite different. The model has has_many associations. These Associations is being managed with

rails partial rendering with uniq id

懵懂的女人 提交于 2019-12-11 14:23:56
问题 I'm trying to render a partial on a view when user is pressing a button, so actually it's a list of partials (the same partial is rendered more times) I use cocoon gem to render the partials like this: <%= f.fields_for :features do |s| %> <%= render 'feature_fields', f: s %> <% end %> <div class="f-input for-button to-right"> <%= link_to_add_association 'add more', f, :features, :class => "radius blue button" %> </div> and in my partial I have this code: <% div_id = DateTime.now.to_i %> so

Wicked Gem with cocoon gem and devise user model

江枫思渺然 提交于 2019-12-11 11:44:14
问题 So I have a User model generated with devise , and I am using Wicked gem to give me multiform option on taking more data from the user and storing it in the user model. Everything is working fine but know I'm trying to add another model where user has many degree. I am using cocoon gem to allow me to add extra degrees . I am able to go to the multiform page and enter degree information and even add many more degrees to the user, but when i submit the form i get an error; param is missing or

Rails3 Cocoon Validate Nested Field Count

僤鯓⒐⒋嵵緔 提交于 2019-12-11 08:20:29
问题 I'm having issues validating with cocoon and the number of fields a model is allowed. Using cocoon, rails3, I have a nested form whereby my locations have many links. I need to restrict the number of links each location has to 5. In my location.rb model, I have this: class Location < ActiveRecord::Base has_many :links accepts_nested_attributes_for :links, :reject_if => lambda { |a| a[:link_name].blank? }, :allow_destroy => true validate :check_link_count ... def check_link_count if self.links

Cannot destroy existing nested association

旧城冷巷雨未停 提交于 2019-12-11 04:44:39
问题 I have three models: class Answer < ActiveRecord::Base belongs_to :question belongs_to :profile belongs_to :theme has_many :linked_sources attr_accessible :body, :theme_id, :question_id, :linked_sources_attributes validates_presence_of :body, :profile, :question, :theme has_paper_trail :on => [:update] accepts_nested_attributes_for :linked_sources, reject_if: :all_blank end class Answer::LinkedSource < ActiveRecord::Base belongs_to :answer belongs_to :source validates :source, :description,

Update nested_attributes by default

China☆狼群 提交于 2019-12-11 01:25:27
问题 I try to update iproduction, a nested form from production and I have an error of params with this line : "wrong number of arguments (0 for 1)" @production.update.iproductions_attributes(cow_id: @cow) My create action production: def create @production = @ranch.productions.create(production_params) @production.update(date: Date.today) @cows = @ranch.cows @cow = Cow.find_by(id: params[:id]) @production.update.iproductions_attributes(cow_id: @cow) respond_to do |format| if @production.save

Update multiple checkboxes on association model through nested attributes | Cocoon gem | Rails

巧了我就是萌 提交于 2019-12-10 12:22:23
问题 I have a House model, which has_many house_rules class House < ActiveRecord::Base has_many :house_rules, dependent: :destroy accepts_nested_attributes_for :house_rules, reject_if: :all_blank, allow_destroy: true end Here is the house_rule model class HouseRule < ActiveRecord::Base belongs_to :house enum rule_type: { predefined: 0, user_defined: 1 } enum allowed: { no: 0, yes: 1 } end Here are the other columns of house_rules table create_table "house_rules", force: :cascade do |t| t.integer

Rails cocoon nested form only receiving one first nested attribute

穿精又带淫゛_ 提交于 2019-12-10 11:29:21
问题 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

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

核能气质少年 提交于 2019-12-08 18:12:30
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 color. This is the JQuery I'm using, where .product-still-form is the image. jQuery(function($) { $("

how to dynamically add nested attributes in rails with jquery

强颜欢笑 提交于 2019-12-08 09:55:04
问题 I've been asking iterations of this question for a while now - but with a lot of help from the SO community i've very nearly got it working. So first, thanks! I have a form to create a new student_group and am using the Cocoon gem: <%= form_for @student_group do |f| %> <p> The name of this group is <span class="field form_field"><%= f.text_field :name %></span> and it is a/an <span class="field dropdown"><%= f.select :type_of_group, [["select a group type", ""], "young learners class (0-6)",