added keyword search to find session

This commit is contained in:
Brian Smith 2013-02-02 18:55:26 -05:00
parent ceaf4119af
commit 9769ade049
1 changed files with 2 additions and 1 deletions

View File

@ -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?