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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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
On 7 Mrz., 15:20, Eva <eva.hai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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!
On Mar 7, 9:41 am, Thorsten
<duple...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> 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
>
> On 7 Mrz., 15:20, Eva
<eva.hai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > 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!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---