Here is my papers table:
title:string
duration:integer
exam_at:datetime
paper_id:integer
author:string
and here is my author table:
name:string
email:string
telephone:string
author_id:string
I have created views for both of these table, and I have implemented the
CRUD structure for them both, but there is one small problem I have.
when it comes to creating a new paper, and generating the value for the
author value in the papers table, I want to use a select drop down menu
that consists of the names of all the authors in the authors table (so i
can select which author created the paper).
right now I have the html code displayed like this:
<% form_for(@paper) do |f| %>
<%= f.error_messages %>
<%= f.label :title %><br />
<%= f.text_field :title %><br />
<%= f.label :duration %> (Minutes)<br />
<%= f.text_field :duration %><br />
<%= f.label :exam_at %><br />
<%= f.datetime_select :exam_at %>
<%= f.label :paper_id %> ID<br />
<%= f.text_field :paper_id %>
<%= f.label :author %><br />
#AREA OF CODE TO BE FOCUSED ON
<select name="select", :author>
<option>Select Author...</option>
<% for author in @authors %>
<option><%=h author.name %></option>
<% end %>
</select>
#AREA OF CODE TO BE FOCUSED ON
<%= f.submit "Create" %>
<% end %>
Obviously this code will produce a drop down menu that shows the names
of all the authors, but will not save to the table, because it is not
being held by ''f''. I was just wondering if anybody new the
code for this
(should start with "<%= f.select" I believe.
Hope someone can help
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---