使用普通的非远程请求时,此表单可以100%运行。但是当我设置remote =>是的,它不再发送提交值。我应该完全不同地做这件事,还是我缺少什么?
<%= form_tag [voteable, Vote.new], :remote => true do |f| %>
<strong class="votes_balance"><%= voteable.votes_for - voteable.votes_against %></strong>
<%= submit_tag :up, { :name => "thumb_direction", :class => "vote_up" } %>
<%= submit_tag :down, { :name => "thumb_direction", :class => "vote_down" } %>
<%= hidden_field_tag :voteable_type, voteable.class %>
<% end %>
authenticity_token /8Dkx/EQc+VqgZd8f/eoWevm8AIgOwK0rzXqlGUzDUA=
utf8 ✓
voteable_type Article
authenticity_token /8Dkx/EQc+VqgZd8f/eoWevm8AIgOwK0rzXqlGUzDUA=
utf8 ✓
voteable_type Article
thumb_direction up
答案 0 :(得分:0)
可能有一种更简洁的方式,我也简单地尝试了button_to方法,但无法弄清楚如何将其全部压缩。
<div id="votes" class="thumbs_up">
<%= form_tag [voteable, Vote.new], :remote => true do |f| %>
<%= hidden_field_tag :voteable_type, voteable.class %>
<%= hidden_field_tag :thumb_direction, "up" %>
<%= submit_tag :up, { :class => "vote_up" } %>
<% end %>
<strong class="votes_balance"><%= voteable.votes_for - voteable.votes_against %></strong>
<%= form_tag [voteable, Vote.new], :remote => true do |f| %>
<%= hidden_field_tag :voteable_type, voteable.class %>
<%= hidden_field_tag :thumb_direction, "down" %>
<%= submit_tag :down, { :class => "vote_down" } %>
<% end %>
</div>