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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:29:51+00:00 2026-06-02T22:29:51+00:00

I have a form for users to upload pictures with some other informations like

  • 0

I have a form for users to upload pictures with some other informations like name and description. I have two databases tables: one is albums and the other is photos. In photos table there is a field called album_id which connects the photo to the album.

<%= form_for(@photo, :html => { :multipart => true }) do |f| %>
  <div>
    <div class='form_text'> Add Photo </div>
    <%= f.file_field :image %>
  </div>
  <div>
    <div class='form_text'> Name </div>
    <%= f.text_field :name %>
  </div>
  <div>
    <div class='form_text'> Description </div>
    <%= f.text_field :description %>
  </div>
  <div>
    <%= collection_select(:album, :album_id, Album.all, :id, :name, :prompt => true)  %>
  </div>
  <div>
    <%= f.submit 'Upload' %>
  </div>

So my problem is that how I can pass the selected value of album_id as same as other values. Maybe I am not clear enough, I think the selection is not added into the f object, so when the value passes when click on Upload, name, description and the photo are passed in as one object and the album_id is passed as another object. How can make the selection into the f object?

  • 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-02T22:29:52+00:00Added an answer on June 2, 2026 at 10:29 pm

    I think it should be

    <%= collection_select(:photo, :album_id, Album.all, :id, :name, :prompt => true) %>
    

    So it would generate a select with the id photo[album_id], as your other fields (doc).

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

Sidebar

Related Questions

I have a form where users can upload files, and I'd like to name
I have a form where users can upload Pdf files(about 30 pages to one
I have a form where users can upload Pdf files(about 30 pages to one
I have a product form that users can upload 5 pictures simultaneously. Everything is
I have a form whereby Users upload pictures as part of their registration process.
I have a form in my django app where users can upload files. How
I have a form that lets users upload a image of them self. I
I have a form which includes 3 textfields so users can upload files. They
I have a form for managing users, a ModelForm type. But for two fields
If I have form where user can upload files via Ajax (and upload is

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.