Ruby on Rails: undefined method for self action in model? -
i'm getting undefined method text_search
, have method in model, doing wrong?
searches_controller.rb
class searchescontroller < applicationcontroller def index @lists = list.text_search(params[:query]) end end
search.rb
class search < activerecord::base def self.text_search(query) if query.present? where("name @@ :q or description @@ :q", q: query) else scoped end end end
however, i'm still getting undefined method. have ideas?
it should search
not list
@lists = search.text_search(params[:query])
because using class search
in search.rb
Comments
Post a Comment