Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:09:24+00:00 2026-06-03T09:09:24+00:00

How do I create a nested form for 2 scaffolded models? I have a

  • 0

How do I create a nested form for 2 scaffolded models?

I have a Syllabus model, which has many Missions. Previously, the only way to create Missions was through the Syllabus nested form (which I made with Railscasts). Yesterday, I decided that users should be able to create Missions by itself, so I scaffolded the Missions while skipping the migrations, so it created all the controllers and views for the existing Missions Model.

So here’s the problem: I can now create Missions by itself, but when I try to create Missions through the Syllabus nested form, it gives me an error “undefined method `difficulty’ for #<\Mission:0xb372ffc.>” I’m guessing it’s trying to pass in the Syllabus attributes to the Missions attribute, which isn’t defined in the Missions schema. (difficulty is an attribute only for Syllabus).

To sum up: Nested forms worked with “builder” when I only had Model for Missions, but when I scaffolded the Missions so it could exist by itself, I couldn’t use the nested form.

Because there were more than a couple files that may affect this, I created a gist.
https://gist.github.com/2631734

Btw, these are the params that should be passed in

{"utf8"=>"✓",
"authenticity_token"=>"YxkzNmIJl0jBA467tdHP2zqNv22DgKrzSx+WCFgwKtk=",
"syllabus"=>
    {"category"=>"Technology and Internet",
    "difficulty"=>"Beginner",
    "title"=>"missions testing",
    "description"=>"deccrip",
    "missions_attributes"=>
        {"0"=>
            {"_destroy"=>"false",
            "title"=>"plz",
            "content"=>"<p>\r\n\tdad</p>\r\n"
            }
        }
    },
    "commit"=>"Create Syllabus"
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:09:26+00:00Added an answer on June 3, 2026 at 9:09 am

    I figured it out, but it is really messy… I’m sure there’s a better way to do it, but after struggling with this for a few days, I’m more than happy with this solution:

      @syllabus = Syllabus.new(:title => params[:syllabus][:title], :category => params[:syllabus][:category], :difficulty => params[:syllabus][:difficulty], :description => params[:syllabus][:description], :author_id => current_user)
    
      @syllabus.save!
    
      params[:syllabus][:missions_attributes].each do |a, b|
    
        @mission = Mission.new(:title => b[:title], :content => b[:content], :syllabus_id => @syllabus.id, :author_id => current_user, :category => @syllabus.category)
    
        @mission.save!
    
        end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this rails cast to create a nested form: http://railscasts.com/episodes/196-nested-model-form-part-1 I have a
I have a nested form with the following models: class Incident < ActiveRecord::Base has_many
I have a nested form (using accepts_nested_attributes_for in respective models): <%= form_for(:technician, :url =>
I have a nested Form A Crew can have many meetings, a Meeting can
I have a nested model form that isn't functioning properly. The POST is to
I am following the Rails guide for doing multi-model nested form. I have 2
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
I have a nested form categories for stores resource. They have a has_and_belongs_to_many relationship.
I'm trying to add has_many_through relationship through a form nested in a parent model.
I am trying to create a custom nested form in RailsAdmin for one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.