我正在尝试创建一个提交到当前控制器(results_controller)中某个操作的表单。
我的表单代码是:
<%= form_tag(:controller => "results", :action => "filter", :id => "filter") do %>
在results_controlle.rb中我有:
def filter
#setting dispatches
@dispatches = Dispatch.find_by_message_ids(params[:message_ids]) unless params[:message_ids].blank?
unless @dispatches.blank? || @input_messages.blank?
@output_messages = OutputMessage.find_by_dispatch_ids(
@dispatches.collect{|d| d.id }.uniq
)
end
respond_to do |format|
format.html #default rendering
end
end
然而我得到了错误:
Unknown action
The action 'filter' could not be found for ResultsController
有什么建议吗?
更新 在同一页面上,我有一个可行的表单:
<%= form_tag(:controller => "results", :action => "show", :id => "show") do %>
答案 0 :(得分:0)
尝试改为
<% form_tag(filter_result_path(), :method => :get) do %>
并添加到您的路线表
resources :results do
member do
get 'filter'
end
end