Hi all, I am wondering if any of you know how to make multiple search methods in one model?
currently I have a search method that has been declared in the model, but I want to create another separate search for different criteria in the database table. How would I do that?
I currently have the following in my games.rb
def self.search(search) if search find(:all, :conditions => ['game_name LIKE ?', "%#{search}%"]) else find(:all) end end
the following in my games_controller.rb
def index @games = Game.search(params[:search]) end
and the following in my index.html.erb
<%= form_tag games_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :game_name => nil %>
<% end %>
Any help would be much appreciated. Thanks