# Rails Tire: How to exclude the current\_user.id by passing it to the model and exclude with tire must\_not?

**URL:** <https://discuss.elastic.co/t/rails-tire-how-to-exclude-the-current-user-id-by-passing-it-to-the-model-and-exclude-with-tire-must-not/10585>\
**Category:** Elasticsearch\
**Created:** [February 1, 2013, 10:13am UTC](https://discuss.elastic.co/t/rails-tire-how-to-exclude-the-current-user-id-by-passing-it-to-the-model-and-exclude-with-tire-must-not/10585 "2013-02-01T10:13:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordan\_Lance](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jordan\_Lance](https://discuss.elastic.co/u/Jordan_Lance)\
**Post date:** [February 1, 2013, 10:13am UTC](https://discuss.elastic.co/t/rails-tire-how-to-exclude-the-current-user-id-by-passing-it-to-the-model-and-exclude-with-tire-must-not/10585/1 "2013-02-01T10:13:03Z")

</div>

Im trying to exclude current\_user.id from my Tire search results but cannot  
figure how to pass a param to Tire and use that instead of a fixed value  
for search.  
**_How could one pass the current\_user.id to the model and exclude it in  
search results?_**  
Searched for this for hours hope someone knows a solution.

**_Activerecord way:_**

```
Profile.where("user_id != ?", current_user.id)

```

**_My tire search block:_**

```
if params['people']
  tire.search(load: true, page: params[:page], per_page: 20, 

```

:default\_operator =\> 'AND') do  
query do  
boolean do  
must\_not { string 'user\_id: 1' } \<== this works hardcoded  
must\_not { string 'user\_id: \< instead of 1 user current\_user.id  
pass in true params?' }  
end  
end  
to\_curl  
end  
end

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:53am UTC](https://discuss.elastic.co/t/rails-tire-how-to-exclude-the-current-user-id-by-passing-it-to-the-model-and-exclude-with-tire-must-not/10585/2 "2017-07-06T02:53:36Z")

</div>

Closed on July 6, 2017, 2:53am UTC


