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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:29+00:00 2026-06-14T17:35:29+00:00

I have a column of product views in a database (e.g. top, bottom, front,

  • 0

I have a column of product views in a database (e.g. top, bottom, front, back). I’m trying to generate a series of file inputs to allow the user to upload an image for each view. This is the result I’m after:

...
<label>Top</label>
<input type="file" name="image[Top]"><br>
<label>Bottom</label>
<input type="file" name="image[Bottom]"><br>
<label>Front</label>
<input type="file" name="image[Front']"><br>
...

This is what I’m trying:

<%= views = View.order('name ASC').all.map { |view| [view.name, view.id] } %>
<%= views.each { |view| label(view); file_field('image', view) } %>

However, all this does is print out the views array a couple of times. Hopefully you Rails experts can point me in the right direction. (I apologize in advance if I’m butchering Ruby.)

  • 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-14T17:35:30+00:00Added an answer on June 14, 2026 at 5:35 pm

    I’d suggest to move your logic out of the view into controller or helper method . Your views_controller.rb :

    @views = View.all.order('name ASC')
    

    This gives you an array of instance objects , which means you can access the view name simply by :

    @views.each do |v|
       var = v.name
    # other code for iterating on View ...
    end
    

    Now , in your view (which should be a form_for or form_tag , so you can choose images and upload them ), you can :

    <%= form_for(@catalogue) do |f| %>
      <%= @views.each do |v| %>
        <%= f.label v.name %>    < br/ >  
        <%= f.file_field v.name %>
      <% end %>
    
      <% f.submit %>
    
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with column for storing product code. | product_id | Product-name
I have an integer column in my table. It is product id and has
I have a product table where the description column is fulltext indexed. The problem
I have a table [Product] with a column [CreateTime] datetime null, and is has
I am using Mysql database. I have 3 table-: table Column tier_price customer_id,sku(Unique),price,website catalog_product
I have a question to the following procedure: script/generate scaffold product title:string description:text db:migrate
I have a Products table in SQL Server database, it has an ID column
I have a 4 column table of products in template,each item in table has
I have a products table with a column of type SET (called especialidad), with
I have a table of product information with many bit columns. This table can

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.