nested-forms

Using Formtastic's semantic_fields_for with a has_many association

I am trying to create a nested form using formtastic. I've included my code below but am running into some problems that I've also listed below. Any suggestions? Thanks. # Home model class Home < ActiveRecord::Base has_many :home_members accepts_nested_attributes_for :home_members, :reject_if => :all_blank, :update_only => true, ...

Static Nested Elements in Rails

I have a list of 'Interests' that each user in my system has the ability to rate. An admin can add/remove Interests at any time. When the user goes to edit their account, I want to show a list of all the Interests in the system, and a drop down with a 1..5 value. I am wondering how I set this up.. Using accepts_nested_attributes for doe...

nested form & update_attributes

i am having trouble updating data in a multi-level nested form. i use partials to include all the fields for both the create & update views, and i do NOT have a problem with creating. only with updating. essentially the structure (simplified) is: user has_one profile profile has_many addresses form_for @user do |u| u.fields_for :pr...

Deeply nested Rails forms using belong_to not working?

I'm working on a messy form which among other things has to manage a section with two-level nesting. It's almost working, but there's a snag and the only thing I can see that's different from other deeply-nested forms that work is that there's a belongs_to relationship rather than has_many. Here are the models: Event has_many :company...

Possible to eager load associations with nested_attributes?

Just briefly, I have run into a dreaded 2(n) queries problem. If n = the number of skills in the database, then my characters#edit form will take 2(n) queries to load the page. It will SELECT a PlayerSkill (the join table) once every skill, and it will look up the Skill once per skill. Here is some code which I believe is pertinent to t...

rails3 html5 jquery dynamically added nested forms, presenter pattern ?

Job has many task, task has many notes How should such a form look like ? With partials so I can enter the whole job from /jobs/new , and add new tasks from /jobs/2/tasks/new with possibility to add notes from there, and of course the possibility to add new notes from /jobs/2/tasks/5/notes/new ? Is this a good place to use the presente...

Reusing form nested and not nested, how to show submit button

I'm learning rails and building a recipe app. In my app, a Recipe has a bunch of ingredients. I've got my ingredients form nested within my recipe form, and I call it with a partial. Of course, because the form is nested, the <%= f.submit %> is in the recipes/_form.html.erb page. So now I'm trying to edit a single ingredient outside...

Set an attribute inside a join model

Hi, I have the following User model: class User < ActiveRecord::Base has_many :competences has_many :skills, :through => :competences accepts_nested_attributes_for :skills end and the following Skill model: class Skill < ActiveRecord::Base has_many :competences has_many :users, :through => :competences end The Competenc...

ASP.net - Problem with integrating form

The WorldPay payment gateway suggests using this HTML to take the customer to the payment page: <form action="https://select-test.wp3.rbsworldpay.com/wcc/purchase" name="BuyForm" method="POST"> <input type="hidden" name="instId" value="211616"> <input type="hidden" name="cartId" value="abc123"> <input type="hidden" name="currency" valu...

accepts_nested_attributes_for and new records

Hi, I'm using accepts_nested_attributes_for with the following models: User model: class User < ActiveRecord::Base has_many :competences has_many :skills, :through => :competences, :foreign_key => :skill_id accepts_nested_attributes_for :skills end Skill model: class Skill < ActiveRecord::Base has_many :competences has_m...

accepts_nested_attributes and validates_uniqueness_of

The central problem: How do you merge attribute collections by a key during mass assignment from a nested form. The details: I am using the following models: class Location < ActiveRecord::Base has_many :containers, :dependent => :destroy, :order => "container_type ASC" validates_associated :containers accepts_n...

Rails many-to-many fields_for: How to access fields_for values?

Hi folks, I'm trying to created a set of nested (many-to-many) forms in rails 3. Everything works fine thanks to fields_for, but I need to put a title above each nested form. That title has the value of the profession_type.name field (which has a prepopulated value) in each respective nested form. I'm having a heckuva time extracting t...

How do you make a form out of a polymorophic table?

I am trying to create a comment that could comment on other comments but are all derived from a single post. What is especially troubling for me is trying to figure out how to make it so that this can all be achieved in the post show and not its edit or new. Is this archtecturally reasonable? That way I can access it via Post.comments,...

How do I display error messages for nested resource validations?

I'm creating a basic blog application and I'm running into issues displaying error messages when a user tries to submit a blank comment. Instead of getting a nice looking error message, an active record error message with the correct validation erorrs. Such as ActiveRecord::RecordInvalid in CommentsController#create Validation ...

Creating a form with a duplicatable nested form inside of it :: A Complex Form Question

I am making a self duplicating form. It can create multiple instances of itself. The hiearchy is, an Organization has_many Referrals. There should be no 'updating'. It should be only a 'create'. My error is : Unknown action No action responded to update. Actions: create and new My Form: - form_for @organization, :url => organizat...

Ignore validation failure when using accepts_nested_attributes_for (i.e. prevent rollback)?

So suppose I have the Person and Child models: class Person < ActiveRecord::Base has_many :children accepts_nested_attributes_for :children end class Child < ActiveRecord::Base belongs_to :parent, :class_name => "Person" validates_presence_of :name end Now when I use a nested form and save a Person with 2 new children...

Anyone know how to save many objects in one form?

I am trying to save many new objects in a form to one pre-existing parent object. - form_for :parent_object do |f| This is the beginning of my form. And then within it, I would do: - 2.times do - fields_for :child_object do |f| Now if I were to save this, it would render as an ParentObject_Controller Update action which would...

Rails 3 nested forms with has_many :through, entry in join table dosen't get deleted after update

Hi, i have a 'User' model which has a has_many relationship to a 'Number' model through a join table 'user_number' model. I use accepts_nested_attributes_for :numbers, :allow_destroy => true in the 'User' model. Everything works fine except that whenever i delete a number from a user in the edit form, the associated number is deleted ...

Rails Nested Form - Filter by Current User, Lesson-Questions-Answers-Users

Hi All, I have a nested form that is based on the following model -- A lesson has many questions, each question has many answers, and answers belong to users. I am developing a nested form, so that a new user can review the questions and post answers. If a user has entered answers in the past, I want those to show up; otherwise show ...

HABTM relationships and accepts_nested_attributes_for

I have a form that lets me create new blog posts and I'd like to be able to create new categories from the same form. I have a habtm relationship between posts and categories, which is why I'm having trouble with this. I have the following 2 models: class Post < ActiveRecord::Base has_and_belongs_to_many :categories attr_accessibl...