I am very new in Ruby and JavaScript, so I not sure about what I am doing. I have a dropdown box that I would like to show by unique name.
My problem is how can I get both ids? When I select a object the value is the id, and the text method is the name. For example, if I have 3 objects with the same name, I need to get three ids. Now, I am getting just one.
Is there another way to do it? Thanks a lot!
TABLE OBJECTS
ID
NAME (I have duplicates in name)
MODEL
UNIQUE INDEX (NAME, MODEL)
You will want to do your select based on the name of the object. Something like
MyModel.find_by_name(params[:name])
This will require you to send the name
of the item to the server instead of the id
. You are probably currently doing something like
MyModel.find(params[:id])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.