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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:14:41+00:00 2026-06-04T08:14:41+00:00

Adapted from the nested form Railscast , I have: In my model class Post

  • 0

Adapted from the nested form Railscast, I have:

In my model

class Post < ActiveRecord::Base
  has_many :fields
  accepts_nested_attributes_for :fields
end

class Field < ActiveRecord::Base
  belongs_to :post
end

In my controller

def new
  @post = Post.new
  4.times { @post.fields.build }

  respond_to do |format|
    format.html
  end
end

In my view

<%= semantic_form_for @post do |f| %>

  <%= f.inputs do %>
    <%= f.input :title %>
  <% end %>

  <%= semantic_fields_for :fields do |h| %>
    <%= h.input :name %>
  <% end %>

  <%= f.buttons do %>
    <%= f.commit_button %>
  <% end %>
<% end %>

The problem is that this only generates one :field input even though i ran @post.fields.build four times. I can’t figure out how to generate multiple inputs so the user can enter multiple fields.

Sorry if this is obvious but I’m new to Rails and pretty new to programming overall.

  • 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-04T08:14:42+00:00Added an answer on June 4, 2026 at 8:14 am

    Your nested form ain’t correct
    Change <%= semantic_fields_for :fields do |h| %> to
    <%= f.inputs :for => :fields do |h|%>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following models adapted from http://www.djangoproject.com/documentation/models/generic_relations/ class TaggedItem(models.Model): A tag on an item.
I have a simple java project (adapted from the example here ), which is
I have created a UIScrollView in my app - adapted from this sample code:
I have the following code adapted from a previous question/answer: var str = $('title').text();
I have an android application which in its main activity, data are adapted from
So: I have the following function, adapted from a formula found online, which takes
I have the following script (adapted from here) for uploading files via ftp for
I have a project with a base view controller class, that is inherited by
I have the following instance method (adapted from Listing 3-6 of the Event Handling
I have a reasonably simple split view application adapted from iPhone code. The main

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.