Displaying 20 results from an estimated 3000 matches similar to: "Using now() to determine what should be displayed"
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 Jun 15
1
Multiple :conditions?
How do I add multiple conditions to a paginated list? I have:
@post_pages, @posts = paginate(:posts,
:per_page => 10,
:conditions => [ ''(title) OR (body)
LIKE ?'', ''%'' + params[:query] + ''%''],
:order =>
2006 Feb 07
11
breaking down a list view
I''m trying to figure out how to change the order of a list view and it''s
obvious to me that I don''t understand what I get from a simple scaffold
to know enough to alter it.
If someone would be so kind to tell me what this means ...
def list
@placment_pages, @placements = paginate :placements, :per_page => 10
end
@placement_pages, # I am guessing that this
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 Feb 08
7
DRY methodology
because I am a grasshopper...
Now that I can sort my ''list''...is there a logical way of not repeating
myself to having essentially the same list view with multiple sorts?
i.e.
def list_cl
# ordered by clients last name
@placement_pages, @placements = paginate(
:placements,
:include => [:client],
:order_by =>
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 Aug 07
4
Problem with Pagination
Hi Guys,
I am trying to paginate the results from a search. When I use actual
constants in the search conditions, it works fine:
def query
@k2_result_pages, @k2_results = paginate (:k2_results,
:conditions => [''e_date >= ? AND
e_date <= ?'', ''2006-07-12'', ''2006-08-12''],
2006 May 14
4
searching on foreing keys
Hey all,
I''m using a simple search function. It''s working
great except for foreign keys.
I have one table pets (id,name,owner_id)
and another table people(id,name)
owner_id being a foreign key of pet pointing to people name.
here it is on the pet controller:
@paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id
like
2006 Aug 14
5
Tutorial for Queries
Hi! I''m looking for a good tutorial that explains the main points of
performing queries with Rails. I do have AWDWR and have read the
section on ''find'' but I''m looking for something that goes into more
detail on how to perform queries across tables.
Abstracted from my current application, this is an example:
* person has_many sites
* site has_one room
*
2006 Jun 08
9
find :order =>
Hi,
I have the following find statment
@client_pages, @clients = paginate :clients, :per_page => 20, :order =>
"organisation_id, surname"
currently im ordering by organisation_id however I need to order by the
field in the organisation table organisations.name
how can this be done?
Thanks
Scott
--
Posted via http://www.ruby-forum.com/.
2006 Apr 16
7
table sorting
Ahoy,
I checked the API and did some forum searches but didn''t find anything
good on table sorting.
Is there a "railish" way to do this? My current method really is lacking
(i''m on like rails day 2)
<th><%= link_to ''Name'', :action => ''list'', :order => ''name'' %></th>
2006 Apr 10
9
Pagination with letter (A B C D ... Z)
Hi there,
Is there a neat and easy way to implement pagination with letters
rather than numbers eg :
A B C D ... Z
Rob
2006 May 23
1
Re: Wierd pagination problem - Unknown options:
> Unfortunately I still get the same error. Here is my code now (the
> commented line works):
>
> def list
> @upload_pages, @uploads = paginate(:uploads, :per_page =>
> 20, :order
> => ''id'')
> # @upload_pages, @uploads = paginate(:uploads, :per_page => 20)
> end
You may have an older version, try using the order_by clause
2006 Jun 25
1
Sorting ferret results by column
I have the acts_as_ferret plugin installed. Everything searches great,
but I would like to limit the results (i.e. by ''end_date'') and sort them
(by ''end_date''). ''end_date'' is a valid column in my "posts" table.
Here''s the code I have already:
@posts = Post.find_by_contents(params[:query])
params[:query] comes from a form. I
2006 Jan 19
8
Pagination_links without "?page=" but with params[:id]
Hello,
With default pagination I have this :
<a href="/users/infos/3?page=1">1</a>
<a href="/users/infos/3?page=3">3</a>
but i need this :
<a href="/users/infos/1">1</a>
<a href="/users/infos/3">3</a>
I need to remove the "?page=" parameters and rewrite a little the link ( with a link_to ? )
2006 Jun 08
3
MVC and Pagination
Just wondering how to best integrate with pagination and still stick to
MVC...
Say I have a Post model that has a published attribute. I want to show
all the recent published posts on a page.
My first instinct is to create a method in the Post model called recent
that does the find with proper conditions and order, but the problem I
have is how do I use that with pagination (which definitely
2006 Apr 06
6
pagination question
i''ve figured out how to use the next and previous links with the
paginator class but now i''m trying to figure out how to display all the
page numbers in between. looking through the rails api, i found
paginator.each() but i''m not sure how to use it, or if that''s even what
i am looking for.
also, is there a way to limit the amount of pages like some sites
2006 Aug 17
8
Creating queries..
Hi, I am trying to implement a few queries now. What are good ways to do
this?
Right now, I have a list page that does sorting and can carry out a
generic pagination request.
@user_result_pages, @user_results = paginate(:user_results,
:per_page => 20,
:conditions => @condition,
:order_by => @sort_order)
I create @sort_order earlier in the list function. The problem I am
having is
2006 May 23
5
Wierd pagination problem - Unknown options: order?
I am trying to use pagination with the order option. I am following
examples I''ve seen all over the web, but I am getting an error. My code
seems simple:
def list
@upload_pages, @uploads = paginate :uploads, :per_page => 20, :order
=> ''id''
end
Yet I keep getting this error:
___________________________________________
2006 Jun 25
1
Using AND in :conditions queries
I have what amounts to a simple search engine running through a table
using input from a form. Everything works fine when looking for "title"
or "body" But, when I want to couple that with an AND statement the
search still works fine, but it seems to disregard the AND statements.
Code below:
In the view:
<%= start_form_tag :action=> "show_search" %>