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 8575703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:45:15+00:00 2026-06-11T19:45:15+00:00

I recently followed a tutorial about nested forms by Ryan Bates and did basically

  • 0

I recently followed a tutorial about nested forms by Ryan Bates and did basically the same thing as he did just with other names. I wanted to nest assignments in the order form and I would like to build an assignment for every bun to that order and the user should put a count in the form.

So my controller looks like this

 def new
   @order = Order.new
   @buns = Bun.all
   @buns.each do |bun|
     @order.assignments.build(:bun_id => bun.id)
   end
 end

And the _form partial looks like this

  <%= form_for(@order) do |f| %>
    <div class="field">
      <%= f.label :user_id %><br />
      <%= f.number_field :user_id %>
    </div>
    <div id="assignments" class="field">
      <% f.fields_for :assignments do |builder| %>
        <div id="assignment" class="field">
          <%= builder.label :count, "Anzahl" %>
          <%= builder.text_field :count %>
          <%= builder.object.bun_id %>
        <% end %>
      </div>
    </div>
    <div class="field">
      <%= f.label :due_to %><br />
      <%= f.datetime_select :due_to %>
    </div>
    <div class="actions">
      <%= f.submit %>
    </div>
  <% end %>

The Order model has this part

has_many :assignments
has_one :user

accepts_nested_attributes_for :assignments

And the Assignments model this one:

attr_accessible :bun_id, :order_id, :count
belongs_to :bun
belongs_to :order

As i log the assignments out there are all, which should be build, so why weren’t the fields rendered?

Thanks for your help!

  • 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-11T19:45:17+00:00Added an answer on June 11, 2026 at 7:45 pm

    You are missing an equal sign (=) in your erb :

     <%= f.fields_for :assignments do |builder| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently followed a small tutorial on howto install apache on a systems where
I recently installed xampp, followed the installation. MySQL/apache. (I have same website running on
Right, hi guys, I recently followed a tutorial http://xnadevelopment.com/tutorials/thestateofthings/thestateofthings.shtml where I wanted to create
I recently followed a discussion on the Qt4-interest mailing list about whether it is
So I recently followed this tutorial on making a basic chatroom in Java. It
recently I followed a tutorial on how to create an alert dialog and when
Recently, I have followed a discussion about assignments to expressions in C++ as shown
I recently followed this tutorial for GWT: GWT Tutorial I am new to web
I recently followed this tutorial on Google Cloud SQL and GWT: http://code.google.com/apis/sql/docs/developers_guide_java.html I deployed
I recently followed Ray Wenderlich's Cocos2D tutorial for putting Cocos2D in a UIKit app.

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.