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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:00:32+00:00 2026-06-03T10:00:32+00:00

I am following the Rails guide for doing multi-model nested form. I have 2

  • 0

I am following the Rails guide for doing multi-model nested form. I have 2 models, Page and Picture. Page has_many Pictures. I’m putting the Picture file field within the Edit Page form using fields_for.

Each time I upload an image, the form will add an additional file field to allow for a new Picture to be uploaded.

The behavior I want is for the Page form to only always have one file field which will create a new Picture. I don’t need previous pictures to be editable.

The questions thus are 1) how can I do the above? 2) should I even be using nested form? Because I’m not editing other parts of the Page when creating a picture.

  • 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-03T10:00:37+00:00Added an answer on June 3, 2026 at 10:00 am

    You can just use:

    #routes.rb
    resources pages do
      resources pictures
    end
    
    #PicturesController.new
    @picture = Picture.new
    
    #views/pictures/new.haml
    = form_for @picture 
    #form code here
    

    Or you can place form wherever you want and send it to pictures controller:

    #views/pages/show.haml
    = form_for [@page, Picture.new] do |f|
      = f.hidden_field :page_id, :value => @page.id
      = f.file_field :file #change to your own
      = f.button :submit
    
    #PicturesController
    def create
      @picture = Picture.new(params[:picture])
      if @picture.save
        redirect_to :back, :notice => "success"
      else
        #some code
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a the following rails models: class Release < ActiveRecord::Base has_many :release_questionnaires, :dependent
I have read the following rails guide : http://guides.rails.info/active_record_querying.html in there exemple a client
I have a Rails app with the following (simplified) models: # member.rb class Member
I have got an existing Rails project (Rails 2.3.8) and I got following Model
Hi: In my Rails ApplicationController I have added the following methods (from rails guide
I noticed that in the i18n rails guide, they have the following code: en:
I have been following a guide to install an app called sharebox within rails.
I am trying to assign a form-inline class to the following form in rails
In my Rails project I have the following code: auto_link( h( wrap_long_string(post.text,50) )).gsub(/\n/,<br />)
In my Rails 3.2.3 application I have the following code in the application.html.erb to

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.