A noob here. I've only just started to learn ROR, and I'm having a problem with a drop down menu, that allows the user to select a project from a database. I have the drop down menu working, however instead of the project names, it shows something like Project:0xb61fbdbc.
<%= f.label :project_name %><br />
<%= f.select(:project_name, Project.all, :prompt => "Select a Project") %>
I have searched,and searched and had no luck. Hopefully someone can help.
Thanks in advance.
只要您在Project
模型中具有name
属性,这应该会有所帮助:
<%= f.select(:project_name, Project.all.map {|p| [p.name,p.id]}, :prompt => "Select a Project") %>
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.