我的形式標記在我看來:Rails的控制器未找到路徑
<%= form_tag view_all_rater_path, :method => 'get' do %>
<p>
<%= text_field_tag :search, params[:search], :placeholder => 'Search by Set # or date' %></br>
<%= submit_tag "Search", :class => "btn btn-link", :name => nil %>
</p>
<% end %>
我的控制器動作:
def view_all
if params[:search]
@ratings = RatingSet.find(:all, :conditions => ['id = ? or rating_date like ?', "%#{params[:search]}%"])
else
@ratings = RatingSet.all
end
end
我的路線:
resources :rater, :only => [:index] do
collection do
get :rater_csv
get :view_all
end
end
當我瀏覽到/評價者/ view_all我得到一個No route matches {:action=>"view_all", :controller=>"rater"}
當我運行耙路線後改變了我的路線,以一個單一的資源,我得到:'rater_csv_rater GET /rater/rater_csv(.:format)評價者#rater_csv view_all_rater GET /rater/view_all(.:format)評價者#view_all ' – Yogzzz 2013-02-27 06:51:10
而且這與您在視圖中使用的路線相匹配。 – sevenseacat 2013-02-27 08:41:19