这个问题与这个问题有关:
我的表格:
</br>
<%= 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 %>
我的路线:
resource :rater, :only => [] do
collection do
get :rater_csv
get :view_all
end
end
我的控制器:
class RaterController < ApplicationController
def index
end
def view_all
if params[:search]
@ratings = RatingSet.find(:all, :conditions => ['id = ? or rating_date like ?', "#{params[:search]}", "%#{params[:search]}%"])
else
@ratings = RatingSet.all
end
end
end
我的路线具有单一资源:
rater_csv_rater GET /rater/rater_csv(.:format) raters#rater_csv
view_all_rater GET /rater/view_all(.:format) raters#view_all
我的具有复数资源的路线:
rater_csv_rater GET /rater/rater_csv(.:format) rater#rater_csv
view_all_rater GET /rater/view_all(.:format) rater#view_all
我真的很困惑为什么要定义一个单一的资源raters#view_all
。
当我定义一个单数资源时:uninitialized constant RatersController
当我定义一个复数资源时:undefined local variable or method
view_all_rater_path'`