在我的
rap lyrics explanation site的首页上,用户可以尝试解释具有挑战性的产品线:
alt text http://dl.dropbox.com/u/2792776/screenshots/2010-02-06_1620.png
这是我用来生成这个的部分:
<div class="stand_alone annotation" data-id="<%= annotation.id %>"> <%= song_link(annotation.song,:class => :title) %> <span class="needs_exegesis"><%= annotation.referent.strip.gsub(/\n/,"\n <br />") %></span> <% form_for Feedback.new(:annotation_id => annotation.id,:created_by_id => current_user.try(:id),:email_address => current_user.try(:email)),:url => Feedback_index_path,:live_validations => true do |f| %> <%= f.hidden_field :annotation_id %> <%= f.hidden_field :created_by_id %> <p style="margin-top: 1em"> <%= f.text_area :body,:rows => 4,:style => 'width:96%',:example_text => "Enter your explanation" %> </p> <p> <% if current_user %> <%= f.hidden_field :email_address %> <% else %> <%= f.text_field :email_address,:example_text => "Your email address" %> <% end %> <%= f.submit "Submit",:class => :button,:style => 'margin-left: .1em;' %> </p> <% end %> </div>
但是,将多个这些放在一个页面上是有问题的,因为Rails会自动为每个表单提供一个new_Feedback的ID,每个字段都有一个像Feedback_body这样的ID(导致名称冲突)