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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:16:25+00:00 2026-06-13T06:16:25+00:00

I’ve just installed ActiveAdmin and created a form like: form do |f| f.inputs Details

  • 0

I’ve just installed ActiveAdmin and created a form like:

form do |f|
  f.inputs "Details" do
    f.input :title
    f.input :published_on, as: :datepicker
  end
  f.has_many :images do |images_f|
    images_f.input :image, as: :file, hint: images_f.template.image_tag(images_f.object.image.url)
    images_f.input :description, as: :text, input_html: { rows: 3 }
  end
  f.has_many :topics do |t_f|
    t_f.input :maker
    t_f.input :title
    t_f.input :text
    t_f.input :image, as: :file, hint: t_f.template.image_tag(t_f.object.image.url)
    t_f.input :sort_order
  end
  f.buttons
end

I got quite a few mandatory feels so when I pick an image for within has_many :images and I click on save (knowing it will fail to validate), it shows me the image I picked in the hint which is fine. However, the image input is still shown and if I don’t fill in any form and click submit again, it will again fail to validate but this time the image is gone.

Does anyone know how to prevent this? It’s kinda annoying.

  • 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-13T06:16:26+00:00Added an answer on June 13, 2026 at 6:16 am

    There is no standart way for doing it, HTML file select controls are always initially blank in Rails and other frameworks,
    and this is also enforced by most browsers. So that is not issue of activeadmin I think. This is because
    web page could get you to upload an arbitrary file
    by hiding the select from the user.
    One of the custom options is to use hidden fields of uploaded files and add them if validation failed. So before validation starts you have to save files anywhere (tmp directory or somethong) and store links to them in virtual attribute of your model. After it you have to render hidden fields in your form with links to already uploaded files on your server. And instead if file inputs you can also display links to them with possibility to delete them.

    Another option is to upload files with ajax from other form when you already have your model stored in db.

    If you want files being mandatory for you model, you can mark you model as disabled or use some kind of temporary model , which is copy of your current one. After file become uploaded and model become valid, you can change it’s state to enabled or copy temporary instance to another database table , depends on your choice.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.