我遇到了这个问题,它总是与提交的表格相同。 update_limits操作将在更新顺序提交按钮上调用。哪个应该触发动作update_order。
以下是我的观点:
<h2>Movies</h2>
<h3>List movies</h3>
<%= form_tag(:action => 'update_limits' ,:id => params[:id]) %>
<%= link_to 'create new movie', {:action => 'create',:id => params[:id]}, {:class => 'margin-left'} %>
<div class="spacer"> </div>
Number of movies in reel:
<span class="c1">
<% rr = 1..6 %>
<%= select("limits", "reel_limit", rr) %>
</span>
Number of movies in archive:
<span class="c1">
<% rr = 0..12 %>
<%= select("limits", "archive_limit", rr) %>
</span>
<%= submit_tag %>
<div class="spacer"> </div>
<%= form_tag(:controller => 'admin/photographers', :action => 'update_order' ,:id => params[:id]) %>
<ul id='movielist'>
<span class="header">name</span>
<%
n = 0
while n < @items.length
%>
<li itemID='<%=@items[n].id%>' <%= reel_color_class(n, @limits) %>>
<% if @items[n]["image"] %>
<%= image_tag("/photographer/image/#{@items[n].id}/#{@items[n]["image"]}", :size => "36x20" ) %>
<% end %>
<%=@items[n].name.force_encoding("UTF-8") %>
<span class='col2'>
<%= link_to 'edit', {:action => "edit", :id => @items[n].id} %>
<%= link_to("remove", {:action => "remove", :id => @items[n].id },
{:confirm => "Are your sure?"}) %>
</span>
</li>
<%
n = n + 1
end
%>
</ul>
<input type="hidden" name="neworder" id="neworder" value="" />
<input name="commit" type="submit" value="update order" onclick="neworder.value=(junkdrawer.inspectListOrderNew('movielist'))" />
<div class="spacer"> </div>
答案 0 :(得分:1)
form_tag
方法需要一个块,而你没有给它一个。你应该做这样的事情:
<%= form_tag(:action => 'update_limits' ,:id => params[:id]) do %>
# form goes here
<% end %>
或者甚至更好,如果这是使用form_for
标签对真实对象进行操作:
<%= form_for(@object) do |f| %>
# form_goes here
<% end %>
有关详细信息,请阅读Getting Started guide for Rails。