2011-08-23 61 views
0

我試圖創建一個表單提交給當前控制器(results_controller)內的某個動作。表單提交Unkown Action?

我的表單代碼:

<%= 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 

有什麼建議?

UPDATE 在同一頁上,我有做工作的一種形式:

<%= form_tag(:controller => "results", :action => "show", :id => "show") do %> 
+0

請發佈你的config/routes.rb文件。 – Gazler

+0

@Gazler當我運行'耙路線'我得到︰'/results/show(.:format){:controller =>「results」,:action =>「show」}'和 'results_filter/results/filter (。:format){:controller =>「results」,:action =>「filter」}' –

回答

0

嘗試,而不是

<% form_tag(filter_result_path(), :method => :get) do %> 

,並添加到您的路由表

resources :results do 
    member do 
    get 'filter' 
end 
end