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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:58:27+00:00 2026-05-29T06:58:27+00:00

I have a nested form in which I would like the form fields to

  • 0

I have a nested form in which I would like the form fields to only appear once for uploading a new image, then display the existing images, without any sort of CRUD capability. In essence, on the edit page, just give the option to add images, but not delete or update.

The relationship is a video has many video_images, which use paperclip for has_attached_file :image I’m trying the following in my controller now:

  # GET /videos/new
  # GET /videos/new.json
  def new
    @video = current_user.videos.build
    @newthumbnail = @video.video_images.build

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

And this in my view:

    <%= f.fields_for @newthumbnail do |u| %>
        <%= u.label :image, "Upload New Thumbnail" %> <br />
        <%= u.file_field :image, :class => "image_uploader" %>
    <% end %>
    <p>
      Or select a previous thumbnail
    </p>
    <div id="previous_thumbnails">
      <!-- These will ultimately be dynamically generated as the existing image associations -->
      <div class="previous_thumbnail" rel="1">
        <img src="http://placehold.it/120x90" />
      </div>
      <div class="selected previous_thumbnail" rel="2">
        <img src="http://placehold.it/120x90" />
      </div>
      <div class="previous_thumbnail" rel="3">
        <img src="http://placehold.it/120x90" />
      </div>
      <div class="previous_thumbnail" rel="4">
        <img src="http://placehold.it/120x90" />
      </div>
    </div>

But I end up with the following error:

unknown attribute: video_image

Which tells me that somewhere, there’s a mistranslation of singularity vs plurality. I can see why Rails would singularize it, as it is, in fact, a single entry. However, even overriding the name of the file field, and making name="video[video_image][image]" into name="video[video_images][image]", I get an error like so:

VideoImage(#39741260) expected, got Array(#9591480)

With params sent:

"video_images"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x000000054f1078 @original_filename="Bill OneManBand.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"video[video_images][image]\"; filename=\"Bill OneManBand.jpg\"\r\nContent-Type: image/jpeg\r\n",
 @tempfile=#<File:/tmp/RackMultipart20120205-3582-1xp2duq>>},

So where am I going wrong? I feel like I may be taking the wrong approach to this…

  • 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-29T06:58:27+00:00Added an answer on May 29, 2026 at 6:58 am

    Change this

    <%= f.fields_for @newthumbnail do |u| %>
    

    to this

    <%= f.fields_for :video_images, @newthumbnail do |u| %>
    

    That should let the fields know that they’re part of the video and not just random video_image fields

    Also make sure you have accepts_nested_attributes_for in your video model.

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

Sidebar

Related Questions

I have the following form for photo_album which uses the nested forms feature of
i have view which looks something like this : <% using (Ajax.BeginForm(new AjaxOptions {
I have a form for a model which accepts nested attrs for several other
I have a form that lets me create new blog posts and I'd like
I have a nested json. I want to post it as a form input
Say I have a Textbox nested within a TabControl . When the form loads,
I have a number of tables, which have nested tables. I using jQuery to
I have javascript object which consists of complex array of structures with nested structures
I have a nested list that looks like this: mylist = [['A;B', 'C'], ['D;E',
In my company form, I would like to be able to add products directly.

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.