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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:56:55+00:00 2026-05-22T19:56:55+00:00

I would be really grateful if someone could shed some light on this for

  • 0

I would be really grateful if someone could shed some light on this for me.

I have in my Rails application a form to create new books.

class Book:
has_many  :lnkbookauts,  :foreign_key => "LSA_BOOK_FK", :dependent => :destroy
has_many  :authors,     :through => :lnkbookauts

class Author:
has_many  :lnkbookauts,  :foreign_key => "LSA_AUT_FK", :dependent => :destroy
has_many  :books,     :through => :lnkbookauts

In the new.html.erb form, user can add authors by clicking on a button which displays a popup. User selects the authors from that popup and then clicks on a button which closes the popup and displays the selected author names in a listbox found in my new book form.
All this is done using javascript.

Clicking of the ‘Save Book’ button saves the book entry along with the authors.

The problem is When i click on the ‘Edit’ button, i would like the author names to be displayed in the list box on my edit form but unfortunately currently, that’s not the case.

new.html.erb:

<p class="redLink">List of Authors:- <span><select size=5 id="book_author_ids" name="book[author_ids][]"  multiple selected="true"> </select></span>
<br/>
<%=  link_to add authors, new_author_path, :popup => ['new_window_name', 'height=400 px, width=500 px']%>

my edit.html.erb form also contains the same code for authors.

Is there something missing in the edit form ?

  • 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-22T19:56:56+00:00Added an answer on May 22, 2026 at 7:56 pm

    You need to tell the edit partial where to read the options for that select from. Try putting the following inside the <select>...</select> tag:

    <%= options_from_collection_for_select(@book.authors, "id", "name") %>
    

    (Where I’m assuming that @book is the Book instance being used to build the form, that you want the id of each Author to be the value field of the option, and that Author has a name method which will provide the displayed string.)

    See here

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

Sidebar

Related Questions

I would really appreciate if you could shed light on this problem. I have
I would be really grateful if someone could explain how to show/ Hide UItoolbar
I would be very grateful if someone could help me break through this issue
I would really appreciate it if some of you could help optimize my tables,
I would really like to see a proportional font IDE, even if I have
I would really like to do something like this: Callable<MyObject> myCallable = .... Future<MyObject>
I would really appreciate if you would take a look at this piece of
I have recently designed a web application that I would like to write in
I have a new batch form where user can select books from a div
I have in my rails form the following code: <label>Fruit: </label> <%= f.select(:IST_FRUIT, [['Apple',

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.