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
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.