這個問題涉及this之一:滑軌控制器未初始化常數
我的形式:
</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'`
仍然收到同樣的錯誤'未定義的本地變量或方法view_all_rater_path' – Yogzzz 2013-02-27 07:37:27
'rake routes'輸出是什麼? – 2013-02-27 07:47:28
'rater_csv_rater GET /rater/rater_csv(.:format)raters#rater_csv' 'view_all_rater GET /rater/view_all(.:format)raters #view_all' – Yogzzz 2013-02-27 07:55:58