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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:51:40+00:00 2026-06-01T03:51:40+00:00

I have some nested models in my Rails application. i have an article hat

  • 0

I have some nested models in my Rails application.
i have an article hat has mny properties.

class Article < ActiveRecord::Base
  has_many :properties, :dependent => :destroy
  accepts_nested_attributes_for :properties
end

class Property < ActiveRecord::Base
  belongs_to :article
end

And now i want to edit this in my View so I editet the controler

  # GET /articles/new
  # GET /articles/new.json
  def new
    @article = Article.new
    3.times { @article.properties.build }

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @article }
    end
  end

And also edited the View and the _format.html.erb

 <%= form_for(@article) do |f| %>
  <% if @article.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>

      <ul>
      <% @article.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </div>
  <% f.fields_for :properties do |prop| %>
            <div class="field">
            <%= prop.label :name %><br />
            <%= prop.text_field :name %>
         </div>
  <% end %>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

But there is no way to show up. If i want to create a new Model, i can not see any input fields for the properties.

What have i do wrong?

  • 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-01T03:51:42+00:00Added an answer on June 1, 2026 at 3:51 am

    You’re missing an = in your fields_for line. That is, it should be:

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

Sidebar

Related Questions

I have three models presented in a multi-model form. class Parent < ActiveRecord::Base has_many
I have some nested models that look something like: class Company has_many :managers end
I have the following models: class EventParticipant < ActiveRecord::Base belongs_to :event has_one :user attr_accessible
I have a rails app with some nested data that I'd like to export
I would like to get some nested params. I have an Order that has
I have some nested view models that implement INotifyPropertyChanged . I'd like to bind
I have an event form with some nested attribute models. The additional models are
I have several models that includes nested classes and lists. Many of the class
I have a simple rails app with models project and phase. A project has
I am having some issues with nested models in a form, using Rails 3.1rc4.

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.