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

  • Home
  • SEARCH
  • 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 3601492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:37:43+00:00 2026-05-18T20:37:43+00:00

Why this: # edit.html.erb <%= form_for @product do |f| %> <%= f.fields_for :shop do

  • 0

Why this:

# edit.html.erb
<%= form_for @product do |f| %>
  <%= f.fields_for :shop do |sf| %>
    # Nothing here
  <% end %>
<% end %>

generates a hidden input field:

<input type="hidden" value="23" name="product[shop_attributes][id]" id="product_shop_attributes_id">

?

Relevant controller code:

def edit
  @product = Product.find(params[:id])
end
  • 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-05-18T20:37:43+00:00Added an answer on May 18, 2026 at 8:37 pm

    It’ll be because the @product you’re editing has a shop. Rails has inserted that in the fields_for so that when the form is submitted, it knows which shop those nested attributes are for. It’s default nested attributes behaviour.

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

Sidebar

Related Questions

Why this: # edit.html.erb <%= form_for @product do |f| %> <%= f.fields_for :shop do
Here is the relevant code from views/products/edit.html.erb : <%= form_for(:product, :url => {:action =>
Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %>
I have this html code that i want to edit with jQuery. Here is
Here is my code for my edit.html.erb: <script src=http://js.nicedit.com/nicEdit-latest.js type=text/javascript></script> <script type=text/javascript>bkLib.onDomLoaded(nicEditors.allTextAreas);</script> <div class=row>
I'm trying to use form_for and fields_for in Rails 3 to let me edit
My Artist conroller, edit method looks like this def edit @user = User.find(params[:id]) end
In my Ruby on Rails code, I have the following edit.html.erb file for tasks:
EDIT 9-3-10: I found this blog entry recently that was very enlightening. http://optimizermagic.blogspot.com/2007/12/outerjoins-in-oracle.html There
Edit: This question was written in 2008, which was like 3 internet ages ago.

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.