From 9769ade049274411fd789d29964d1b05b7a13dbd Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 2 Feb 2013 18:55:26 -0500 Subject: [PATCH] added keyword search to find session --- lib/jam_ruby/models/music_session.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jam_ruby/models/music_session.rb b/lib/jam_ruby/models/music_session.rb index 32cd4d030..f47263410 100644 --- a/lib/jam_ruby/models/music_session.rb +++ b/lib/jam_ruby/models/music_session.rb @@ -38,7 +38,7 @@ module JamRuby # This is a little confusing. You can specify *BOTH* friends_only and my_bands_only to be true # If so, then it's an OR condition. If both are false, you can get sessions with anyone. - def self.index(current_user, participants = nil, genres = nil, friends_only = false, my_bands_only = false) + def self.index(current_user, participants = nil, genres = nil, friends_only = false, my_bands_only = false, keyword = nil) query = MusicSession .joins( @@ -89,6 +89,7 @@ module JamRuby } ) + query = query.where("music_sessions.description like '%#{keyword}%'") unless keyword.nil? query = query.where("connections.user_id" => participants.split(',')) unless participants.nil? query = query.joins(:genres).where("genres.id" => genres.split(',')) unless genres.nil?