I have the following code @components_pages = Paginator.new self, Computer.find(params[:id]).components.count, 2, @params[''page''] How can I restrict find to only return associations(components) for the current page? @computer = Computer.find(params[:id] ..................... I spent a few hours thinking about this one but to no avail regards, Leon. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I also has this problem and solved it by using conditions (accroding to the associaltions) in the paginate definition. But I i don''t think this is a nice solution. Are there better ways of doing that ? regards On 11/17/05, Leon Leslie <leonleslie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have the following code > > @components_pages = Paginator.new self, Computer.find(params[:id]).components.count, > 2, @params[''page''] > > How can I restrict find to only return associations(components) for the > current page? > @computer = Computer.find(params[:id] ..................... > > I spent a few hours thinking about this one but to no avail > > --Roberto Saccon - http://rsaccon.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Saccon, Thanks for your quick reply to the post. Do you have an example? It would be cool if one could limit includes in associations, but this is just my mad method of thinking. Can i have a view of your conditions and how you did it? regards, Leon. On 11/17/05, R. Saccon <rsaccon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I also has this problem and solved it by using conditions (accroding to > the associaltions) in the paginate definition. But I i don''t think this is a > nice solution. Are there better ways of doing that ? > > regards > > On 11/17/05, Leon Leslie <leonleslie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have the following code > > > > @components_pages = Paginator.new self, Computer.find(params[:id]).components.count, > > 2, @params[''page''] > > > > How can I restrict find to only return associations(components) for the > > current page? > > @computer = Computer.find(params[:id] ..................... > > > > I spent a few hours thinking about this one but to no avail > > > > -- > Roberto Saccon - http://rsaccon.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- First they laugh at you, then they ignore you, then they fight you. Then you win. -- Mahatma Karamchand Gandhi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Computer.find(:first, :conditions => ["id=?", params[:id]]).components.count __________________________________________________________ or Computer.find(:first, :conditions => ["id=? and price>?", params[:id], 3000]).components.count i hope that''s make sense. -- Posted via http://www.ruby-forum.com/.