nested-forms

nested object forms

I'm a rails and ruby noob, and Im pretty sure this something completely stupid I am missing.. Trying to build a nested form, and have found many examples online, and tried and failed to reproduce the desired result. the "seller" fields are not even displayed, and when I submit form I get: unknown attribute: item models: class...

Rails: Can't get fields_for to work inside a nested resource

Hi folks, I'm trying to add a fields_for attribute to a nested rails form. Any time I try to create a new object, it returns Message(#58819400) expected, got Array(#18903800) ... app/controllers/discussions_controller.rb:53:in `create' If I try to access nested fields_for from forms based on non-nested resources (aka "for...

accepts_nested_attributes_for validation

I'm using Rails 2.3.8 and accepts_nested_attributes_for. I have a simple category object which uses awesome_nested_set to allow nested categories. For each category I would like a unique field called code. This would be unique for the category per level. Meaning parent categories will all have unique codes and sub categories will be ...

Nested Model Forms in Rails For a "Quiz"

Hi, I am trying to build a quiz of sorts. I would like my form to be able to build one question with 4 or more answers. 4 answers are inputted by default with the ability to add more answers dynamically with javascript. I have modeled it off the code in Ryan Bate's railscasts "Nested Model Forms". My dilemma comes with setting the ...

An array of nested forms, but I do not want the previous completed objects to show

I have an Object where the object has a nested form of which can be duplicated as needed. To accomplish this I am using : - 2.times { @organization.referrals.build } - form_for @organization do |f| = f.error_messages - f.fields_for :referrals do |qf| = render :partial => 'referral_fields', :locals => {:qf => qf} Now I have tw...

Prototype Ajax.Autocompleter in dynamically added HTML does not work

Hey, this is the first time I've actually finished writing up a question without SO giving me the answer in the process. :) I've got a nested form (along the lines of Ryan Bates' Railscast tutorial on the topic) which allows users to dynamically add additional fields for adding/removing nested models using Prototype-based javascript. Th...

Correctly instantiating a nested fields_for without showing older saved objects ?

I have a nested form that instantiates as this : - 2.times { @organization.referrals.build } - form_for @organization do |f| = f.error_messages - f.fields_for :referrals do |f| Except, the nested forms are supposed to be always new and unique. Where as this form shows previously created objects as well. So I tried to write as so...

How do you pass options through a fields_for ?

I am trying to run this.. - f.fields_for :referrals do |qf| But I would like to pass this, @organization.referrals.select{|ref|ref.new_record?} as well. This is so that the forms passed are exclusively new objects, and not older ones. I've tried to do this.. - f.fields_for :referrals do |qf| - if qf.object.new_record? = render...