nested-forms

Another rails nested form question..

Trying to perform a nested object form. The page loads with no errors, but when I send it, no information gets saved to the organization model. The SQL call says this .. Parameters: {"commit" => "save", "action"=>"update","_method"=>"put", "organization"=>{"likes_snacks"=>"0"}, .. Which is right. The 1 and 0 can be changed properly ...

Problem with file uploads in a nested form using Rails3 with Mongoid and Carrierwave

Im having a problem transferring an SQLlite Rails 3 app over to a Mongoid Rails 3 app. In the SQLlite version, I am easily able to include an image upload form (using Paperclip) from one model ('image') within a nested form from another model ('product'). Here's my 'new' product form: <%= form_for @product, :html => {:multipart => t...

Multistep Nested Forms Using Rails

I'm trying to implement a multistep form using a nested form, but since I'm using a nested form, it's not working out like the railscast. I got this from railscast #217 (multistep form/wizards) http://railscasts.com/episodes/217-multistep-forms old _event.html.erb form <%= render "event_details", :f => f %> <%= render "sandwich_detail...

Changing which Rails Validations run depending on current user in deeply nested form.

I'm working with a nested form that encompasses a total of 7 models, each with different validations. When simply editing the form, the validations run and display fine, and data is saved properly. However, I need to have different validations run depending on who is submitting the form (ie, admins can skip some otherwise required fields...

symfony : Problem with the method 'embedRelation'

Hello, I have two classes with a relation one-to-many. And I want to make a nested form to enter an object and some of others which are linked to it. But when I save the form, the key wich references my main class isn't update with the key of main class. However the other keys are created. My schema : Enfant: connection: doctrine ...

symfony : Problem with custom post validator

Hello, I have made a nested form using the method 'embedRelation'. In a main form I have twelve child forms. EDIT : $subForm = new sfForm(); for ($i = 0; $i < 12; $i++){ $enfant = new Enfant(); $enfant->Locataire = $this->getObject(); $form = new EnfantForm($enfant); $subForm->embedForm($i, $form); } $this->embedForm('n...

nested attributes and habtm checkboxes working on same form?

Hi I have a task model which has a habtm association with documents, I want the user to be able to upload new documents and automatically associate those documents with the task and also be able to select existing documents to link or unlink with the task I've tried using the nested attributes code and the habtm checkbox code from rai...

How to produce several forms for a nested form ?

Intro I have an object @organization that has_many :quick_facts Basically, I want to produce a _form for each :quick_fact but with one save button, that saves all of the quick_facts. My two problems: First Problem: My quick_facts are not prepopulated with their information. They only appear as blank for each quick_fact I have. Se...

Nested form and link_to_function

Hi everyone! I've got a nested form like this : <% form_for setup_training(@training), :url => admin_trainings_path, :html => { :class => :form } do |f| -%> <!-- begin of form --> <!-- content of :partial => "day_form" --> <% f.fields_for :days do |days_form| %> <%= render :partial => "admin/days/form_inner", :locals => { :f => da...

rails: create Parent, if doesn't exist, whilte creating child record

Any best practices for the following?: I have Manufacturer model that has_many Inventory In my new Inventory form I want a field that maps to Manufacturer.name so that when one submits the new Inventory form the app: searches for a manufacturer with the 'name' from the form if it exists then assign the id to @inventory.manufacturer...

Nested models throws Undefined Method Error

I've been following RailsCast 197 to try this nested models/forms and have cracked my head over this code for over 2 hours, but to no avail. What am I overlooking? I have the following Models: class Workout < ActiveRecord::Base belongs_to :user has_many :performed_exercises, :dependent => :destroy accepts_nested_attributes_for :...

Nested UserControl Render Order

Hi everyone. I have a custom control created in codebehind, and I have in the same control an ordinary asp.net button. Like this: protected void Page_Load(object sender, EventArgs e) { } private void MyTable() { Table table = new Table(); TableRow row = new TableRow(); TableCell cell = ...

How to write properly a nested form with a N-N relation

While working on Rails 3 app, I came to the problem of nested forms. One collection is a set of predefined objects (created with db:seed). The other collection should show a form to allow to choose a few elements. An example is better than a long description, so here it is. Suppose you have 2 models: User and Group. Suppose there are...

Rails Nested Attributes and Custom Validation

I'm fairly new to both Ruby and Rails (using 2.3.8), so forgive me if I'm missing something really obvious here but I've been struggling with this for a while and my searches have been fruitless. In my code I have Plans, and a Plan has many Plan_Steps. Each Plan_Step has a number (to indicate '1st', '2nd', etc). I have a form to update ...

How do I pass an array to fields_for in Rails?

I want to use fields_for on a subset of records in an association. I have a Month model, which has_many :payments. But in my form in my view I only want to have fields_for some of those payments. For example: - fields_for @month.payments.large This doesn't work. Can I pass a set of records to fields_for, rather than the usual symbo...

rails handling single and multiple returned objects

In rails you can use .each do || to loop through the returned results of a query. But what if only one line is returned? or you have the possibility of 0, 1, or many? how do you handle these scenarios without throwing an error? This situation in particular is one where i am accepting nested attributes following ryan's railcast blog (htt...

nested forms using accepts_nested_attributes_for awesome_nested_set

I would like to get full nested (multiple levels) forms working with awesome_nested_set. Currently I've got one level working by adapting Ryans example from his Railscast: http://railscasts.com/episodes/197-nested-model-form-part-2 In my test app I have categories and I would like to go three levels deep eg: Categories -- Sub Category ...

nested form - how to validate parent model based on inputs on child model?

Hi all, Have a nested form, the relationship is like so class Inspection < ActiveRecord::Base has_many :inspection_components accepts_nested_attributes_for :inspection_components class InspectionComponent < ActiveRecord::Base belongs_to :inspection I have a custom validate method in Inspection which depends on attributes enter...

Use accepts_nested_attributes_for to create new records or update existing.

Read the big update for the latest information. Hey everyone, I've got a many-to-many relationship in a rails app that involves three tables: a user table, an interests table, and a join user_interests table that also has a rating value so a user can rate each of their interests on a 1-10 scale. I am basically looking for a way for a ...

Efficient accessor for new_record?s in ActiveRecord relationship?

Just getting through some of the issue backlog and could use some input on best-practices for what seems like it should be a common scenario. (Rails 2.3.5) Let's say we've got form for creating posts for a blog using mass-assignment. The create action looks something like: def create if @blog.update_attributes(params[:blog]) redi...