Displaying 20 results from an estimated 40000 matches similar to: "Find, paginate, conditions and associations"
2007 Apr 04
2
[PLUGIN] ArPaginator - Allows you to easily paginate over any existing AR queries.
The built-in Rails pagination is fairly limited...you pass in the
model name, and optionally some conditions, and it generates a
paginated query for you. This gets to be very bad if you''ve got any
custom queries.
class Company < ActiveRecord::Base
def complete_videos
Video.find :all, :conditions => "company_id=#{id} AND
status=''complete''", :order
2006 May 07
4
Paginate() from multiple tables
Hi
I''m wondering if there''s a way I can gather data from multiple tables
from the child table by using the paginate method?
I would have done it using select_by_sql but I need it to paginate.
My table structure is:
Records is a child of Date and Account
Date Account
| |
^ ^
Records
I want to be able to print a table using the Records controller that
will
2008 Feb 29
7
Moving pagination to the Model
I''m using will_paginate in a Post class method;
[code]def self.list(page)
paginate :per_page => 10,
:page => page,
:include => :user
end[/code]
I can happily use the method on my posts controller index action;
[code]
class PostsController < ApplicationController
def index
@posts = Post.list(params[:page])
respond_to do |format|
2006 May 22
4
use join table in paginate
How come I allways immediately run into difficult stuff when I''m trying
some new programming language? Am I blind for the simplicity of
Ruby/Rail, which a see must be there? Anyway, don''t try and answer this
rhetoric question. I have got another one for you, seemingly difficult.
I''m struggling with a n:m relationship (in a database, that is) and its
join table.
2008 Mar 31
10
Paginate with Rails 2.0.2 question
Hi,
So I''m using @post_pages, @posts = paginate :posts, :per_page => 10
to paginate.
But I have rails 2.0.2 on my VPS. Now this version of paginate throws
an error. What happened to classic pagination and what is done now?
Thanks,
Ron
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
2006 Mar 18
3
paginate a collection
hi i want to paginate a collection found by complex sql query
how can i do
thanks
--
Posted via http://www.ruby-forum.com/.
2006 Apr 05
1
Problem with paginate and conditions
Hi!
I have a search form that calls search action, which executes paginate
method with many conditions using data from the form.
Now if all results don''t fit into a single page, do i have to send all
conditions again to paginate method in link_to previous/next?
If yes, how? All my parameters from the search form are inside a
(nested) hash called ''form'' so i tried to
2006 May 14
3
Beginner question on paginate with params and conditions
I am trying to do a simple search by product name. The first page
returns fine, but when I try to go to any other pages of the search
results, I lose the original search parameters from my search form and
get NilClass errors.
Here is the code in my controller:
namesearch = "%" + params[:name].strip + "%"
@product_pages, @products = paginate :product,
2006 Jun 15
1
Paginating a .find
how exactly would I apply paginate to a .find I have:
@posts = Post.find(:all,
:conditions => [ ''(title) OR (body) LIKE ?'', ''%''
+ params[:query] + ''%''],
:order => ''end_date'')
How would I go about paginating the uoputed list? Something like 10 on a
page.
--
Posted via
2006 Jan 06
2
Paginate from a difficult sql query
Hello,
I have 2 tables
table colors :
+----------------------+
| id | user_id | name |
+----------------------+
| 1 | 1 | test1 |
| 2 | 2 | test2 |
| 3 | 3 | test3 |
+----------------------+
table users :
+----------------------+
| id | enabled | name |
+----------------------+
| 1 | 1 | bob |
| 2 | 1
2006 Jun 21
7
acts_as_taggable and paginate?
Hi there,
I''ve been trying to paginate over a list of members that all share a tag in
common using the acts_as_taggable plugin. The regular way of paginating over
a collection doesn''t seem to work with acts_as_taggable. Here''s what my
method looks like that takes in a tag name, finds all the members that share
the tag and then displays all the members. Nothing too fancy
2006 Jan 31
6
Pagination - why is it this hard?
Hi everyone,
I''m at the end of my rope on this. I can''t get pagination to work
with anything but a standard find on a model. If I try to do a search
and customize the pagination, I get lots of different variations.
My thought was to have the list action do what it does, but to pass it
a list of search conditions from the search action. So, if search
determines that we need
2009 Jul 23
1
How can I paginate records find by using find_by_sql
Hello everyone,
I forced to use @user = User.find_by_sql sql_query in a particular
situation in my project. Now I want to paginate the records. How can I
paginate the records?
Please help me.
Thanks in advance
--
Posted via http://www.ruby-forum.com/.
2006 Feb 28
5
Problem with paginate, include and foreign keys
Hi all,
Solaris 10
Ruby 1.8.4
Rails 1.0.0
Postgres 8.1
postgres driver 0.7.1
I''m having a problem with getting paginate() to properly pick up an FK
constraint properly.
I don''t seem to have this issue with ActiveRecord, however. Consider:
create table start_dates (
id bigserial,
start_date date unique,
max_slots int default 40,
primary key (id)
);
create
2006 Jan 06
4
"Selecting" a calculated row / Using :select in the paginate method
Hi,
I was trying to use the :select parameter to select a calculated row,
but it appears that the parameter is not picked up by the paginate method.
I want to add the following to the select statement:
timediff(now(), created_on) as age
So I tried:
@story_pages, @stories = paginate :stories, {:per_page => 10, :include
=> ''user'', :select =>
2006 Apr 12
1
how do i paginate the results of a query?
I have a controller and list page for region object. My list page has a
''name'' text input that can be used to limit the list.
It works except that the paginate gets the full set of regions unqualified
by my search term. I believe this full list is contained in :regions symbol
which I dont seem to be allowed to modify or replace (yes I am a ruby and
rails newb). How can I
2006 Apr 04
2
Pagination and Parent Conditions
Can I do any "fancy" conditionals when using the Pagination helper?
The problem is that I want to be able to specify a conditional based
on the criteria of a parent object. Here''s an example:
Object A has_many Object B''s
I want to paginate through 100 B''s but I *only* want it to return the
ones who''s A.flag = true
I poked around through the Wiki
2006 Apr 07
2
Paginate single items
Hi,
In my blog i display a post. I want to display a link tot he previous
post if there is 1 and a link tot he next post if there is one.
So i have in my controller
def post
@post = Post.find(params[:id])
@post_pages, @posts = paginate :posts, :per_page => 1
render(:layout => false)
end
And the following code in post.rhtml
<% if @post_pages.current.next %>
<%=
2006 Mar 01
2
Problem with paginate search
Hi,
Firts all sorry for my poor english
I am doing a simple search with paginate, the problem is the search dont
find the words within acutes (example "dont find sal?n if i search salon").
Its the code for the seach:
def search
words = @params[''search''].to_s.split('' '')
array_conditions = []
for w in words
array_conditions =
2006 Jul 23
2
how to paginate child records
hi
i know i can do:
@customer_pages, @customers = paginate :customers, :per_page => 8
but these customers have helpdesk calls which are child records. I hoped
i could do something like paginate customers.calls, but dat doesn''t work
what is the best way to get a paginated list of child records?
remco
--
Posted via http://www.ruby-forum.com/.