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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:05:33+00:00 2026-06-16T19:05:33+00:00

I made a rails application. I am supposed to implement has_many , belong_to relations

  • 0

I made a rails application. I am supposed to implement has_many, belong_to relations between Author, and Location models as follows, and wrote something as:

In models:

class Author < ActiveRecord::Base
  belongs_to :location
end

class Location < ActiveRecord::Base
  has_many :authors
  accepts_nested_attributes_for :authors
end

In location/new.html.erb:

<%= form_for(@location) do |f| %>
  <%= f.label :location_name %>
  <%= f.text_field :location_name %>
  <%= f.fields_for :authors do |a| %>      
    <%= a.label :name %>
    <%= a.text_field :name %>
  <% end %>
<% end %>

My question is, even the location can have many authors, it is showing only one text field for author for the fields_for :authors, then how can I achieve to append as many as text fields for authors according to the user wish?

Can anyone help me please?

  • 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-16T19:05:34+00:00Added an answer on June 16, 2026 at 7:05 pm

    Beautiful tutorial from Ryan Bates:

    http://railscasts.com/episodes/196-nested-model-form-part-1

    http://railscasts.com/episodes/197-nested-model-form-part-2

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

Sidebar

Related Questions

I have made a simple Rails application that allows people to comment on posts.
Wanting to play with jQuery, Orbited, and FasterCSV, I made a Rails chat application.
I have been pondering about developing a new application with rails (probably without models?).
I am trying rewrite a simple Rails application I made a while ago with
I'm attempting, poorly, to implement an achievement system into my Ruby on Rails application.
Ok, so I have a simple rails application and now i'm trying to implement
I've made a NSIS script to create an installer for a Rails application. The
I have a old app made on rails 1.2.5, this application have alot of
I made an application in rails 3.0.9...in that application I have one form which
I am developing application in rails , where i have made use of state_machine

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.