- if params[:q]
- @notes = @notes.joins(:comments)
- if @user
- @notes = @notes.where("to_tsvector('english', comments_notes.body) @@ plainto_tsquery('english', ?)", params[:q])
- else
- @notes = @notes.where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q])
- end
- end
+ @notes = @notes.joins(:comments).where("to_tsvector('english', note_comments.body) @@ plainto_tsquery('english', ?)", params[:q]) if params[:q]