# Pagination\_find outside of find?

**URL:** <https://www.ruby-forum.com/t/pagination-find-outside-of-find/131271>\
**Category:** Rails\
**Created:** [March 7, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/pagination-find-outside-of-find/131271 "2008-03-07T15:21:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dbc845/32.png) [@Eva](https://www.ruby-forum.com/u/Eva)\
**Post date:** [March 7, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/pagination-find-outside-of-find/131271/1 "2008-03-07T15:21:13Z")

</div>

I am selecting records from the database using find. Then I delete  
records out of the array, that I don’t want. That means I have fewer  
records in my array then after the find. Therefore I cannot put the

:page =\> {:size =\> 15, :current =\> page}

into my find.  
How would I do it, if I have the following code to tell my pagination  
the number of records?

@images = Image.find(params[:keyword])  
if @images.empty?  
flash[:notice] = “No Images found”  
else  
@images.reject { |image| image.owner.id != @owner.id }  
end

Please help!  
Thank you!

---

<div class="post-metadata">

**Author:** ![Eva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dbc845/32.png) [@Eva](https://www.ruby-forum.com/u/Eva)\
**Post date:** [March 7, 2008, 4:26pm UTC](https://www.ruby-forum.com/t/pagination-find-outside-of-find/131271/2 "2008-03-07T16:26:29Z")

</div>

its a bad practice to get all records and filter in rails afterwards.  
use conditions.

@images = Image.find(params[:keyword], :conditions =\> “owner\_id =  
#{@owner.id}”)  
unless @images.empty?  
flash[:notice] = “No Images found”  
end

---

<div class="post-metadata">

**Author:** ![Eva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dbc845/32.png) [@Eva](https://www.ruby-forum.com/u/Eva)\
**Post date:** [March 7, 2008, 4:41pm UTC](https://www.ruby-forum.com/t/pagination-find-outside-of-find/131271/3 "2008-03-07T16:41:53Z")

</div>

You are right, but I am using find\_fulltext and I don’t know, how to  
join several tables with find\_fulltext as well as have two arguments  
like “keyword” and “owner\_id”. Also, I don’t know how to add the  
pagination stuff in there. My sql query would look like this:

select value  
from fulltext\_rows f, images i  
where f.fulltextable\_type = “Image” and  
f.value like “%params{:keyword]%” and  
f.fulltextable.id = i.image.id and  
i.image.type = null and  
i.owner\_id = owner\_id;

Thank you!
