undefined method 'search_type'
以下のコードを受け取ります。ここで私が間違っていることを教えてもらえますか?おそらくプライベート関数を呼び出すことと何かがありますが、私は問題が何であるかを見つけることができません。
class Entry < ActiveRecord::Base
attr_accessible :content, :rank, :title, :url, :user_id
def self.search(params)
t, o = search_type(params[:type]),search_order(params[:order])
scope = self
scope = scope.where(t) if t
scope.order(o).page(params[:page]).per_page(20)
end
private
def search_order(order)
return 'comments_count DESC' if order == '1'
return 'points DESC' if order == '2'
'rank DESC'
end
def search_type(type)
return nil unless type.present?
"entry_type = #{type}"
end
end
コントローラーには、しかありません@entries = Entry.search(params)
。