Rails form submit problem having 2 forms
I have that problem it is always the same form that gets submitted. The update_limits action gets called on the update order submit button. Which should trigger the action update_order.
Here is my view:
<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>
The form_tag
method takes a block, and you are not giving it one. You should be doing something like this:
<%= form_tag(:action => 'update_limits' ,:id => params[:id]) do %>
# form goes here
<% end %>
Or even better, if this is acting on a real object, using a form_for
tag:
<%= form_for(@object) do |f| %>
# form_goes here
<% end %>
For more information, please read the Getting Started guide for Rails.
精彩评论