I have this form using the simple_form plugin:
<%= simple_form_for([@video, @video.comments.new], :remote => true) do |f| %>
<%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %>
<%= f.input :body, :label => false, :placeholder => "Post a comment." %>
<%= f.button :submit, :value => "Post" %>
<% end %>
and this creates a drop down list with this line:
<%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %>
My question is how do you modify this code so that each drop down item is a link to each comment_title
's individual show view?
UPDATE
Here is the generated html from the code from the first answer:
<select class="select optional" id="comment_comment_title_id" name="comment[comment_title_id]">
<option value="<a href=" comment_titles="" 224"="">#<CommentTitle:0x10353b890>">#<CommentTitle:0x10353b890></option>
<option value="<a href=" comment_titles="" 225"="">#<CommentTitle:0x1035296e0>">#<CommentTitle:0x1035296e0></option>
<option value="<a href=" comment_titles="" 226"="">#<CommentTitle:0x1035295a0>">#<CommentTitle:0x1035295a0></option>
</select>
I actually figured it out. Here is the ruby code:
This passes the first element in the array as the text, and the second element in the array as the value. Then I use this jQuery code:
Pretty simple.
try
:collection => @video.comment_titles.map {|ct| [ct, (link_to ct, comment_title_path(ct))] }