Displaying 20 results from an estimated 2000 matches similar to: "Using Paginator outside of controllers"
2006 Jul 01
1
Paginator offset =0 ...
Hi list,
I Try to do a custom paginator, but the offset never increase ??
def
showFriends
@friends_pages = Paginator.new self, allFriends.size, 3,
@params[''page'']
limit= @friends_pages.items_per_page
offset= @friends_pages.current.offset
2006 Jan 27
0
custom paginator generating Next link when not needed
I implemented a prefix search using the following custom paginator:
@performer_pages = Paginator.new self, Performer.count, 25,
@params[''page'']
@performers = Performer.find( :all,
:conditions => ["Name >= ?", params[:prefix] ],
:order => "Name ASC", :limit =>
@performer_pages.items_per_page,
:offset =>
2008 Apr 26
0
moving pagination code to model
Hi
I have the controller code as below
# step 1: set the variables you''ll need
page = (params[:page] ||= 1).to_i
items_per_page = 20
offset = (page - 1) * items_per_page
# step 2: instead of performing the full find, just find the
record count
@search_sd_ticket_count_result =
2008 Mar 06
1
pagination for an object array
def show_details
@sd_ticket = ServiceDeskTicket.find(params[:id])
@servicedesk_cis = @sd_ticket.service_desk_cis
end
What I need is a pagination for @servicedesk_cis using the custom
pagination..How can i give offset and limit to this?
I have successfully done previously custom pagination in another def as
below
def search_sd_ticket
@search_sd_ui_hash=params[:sd_ticket]
2007 Jun 20
1
Count_by_content ??
Is there a count_by_content alternative to the find_by_content action?
This is because I''m wanting to do the following in my pagination method:
def list
# step 1: set the variables you''ll need
page = (params[:page] ||= 1).to_i
items_per_page = 20
offset = (page - 1) * items_per_page
# step 2: instead of performing a find, just get a count
item_count =
2008 May 19
0
changed to will_paginate
Hi
Till now we used the rails pagination.But now onwards shifting to
will_paginate
The code I use currently is as below .This is with the help of
find_where pluggin..A fantastic pluggin which we still want to use...I
would like to know how can i modify the following code to work with
will_paginate
step 1: set the variables you''ll need
page = (params[:page] ||= 1).to_i
2005 Dec 29
0
strange output in http header
Hi there,
I''m experiencing something strange in rails http headers. The response
comes back as text/plain. The http header looks like this:
HTTP/1.1 200 OK
Date: Thu, 29 Dec 2005 15:18:18 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-16 mod_ruby/1.2.4
Ruby/1.8.4(2005-10-29)
#<#<Class: 0x40a7f818>:0x40a7f778>Content-Type: text/html
Cache-Control: no-cache
2006 Oct 02
6
Strange Sorting Issues
Hi there,
I''m having some strange sorting stuff goign on. Here''s my search method:
sort_fields = []
sort_fields << Ferret::Search::SortField.new("name",
:reverse => :false)
@results = Listing.find_by_contents @search_criteria, :limit => :all,
:sort => sort_fields
page = (params[:page] ||= 1).to_i
items_per_page = 9
offset = (page - 1) *
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 Mar 13
0
Pagination attributes
I have created a pagination with my own conditions :
@timesheets_pages = Paginator.new self, count, 30, @params[''page'']
@timesheets = Timesheet.find :all,:include
=>{:employee=>[:location,:division]},
:conditions => ["employees.location=?
and employees.division=? and start_date>? and end_date < ?
2005 Dec 23
1
pagination problem
hey,
i have this problem
in the database i have 32 records
and the sql filtered 4 records
#getting the callerid records depending on the given paramaters and paginate it
@callerid_pages = Paginator.new self, CallerId.count, 10, @params[''page'']
@caller_ids = CallerId.find(:all, :conditions =>["geotags.firm_id = ? ",
@firm_id], :order => " geotags.address1
2006 Aug 04
4
DRY DRY DRY
Hello everyone!
Ive been on rails for the last month or so and really enjoyed this
framework.
However its very hard to find documentation on how to do things right!
For example every beginner after a while realizes that having similar
CRUD actions in every controller and views for them is not DRY at all!
Few days ago I found http://dereksivers.com/rails-shared-controller.html
I quite like his
2006 Jul 16
3
pagination over custom-sorted collections?
I have a little web app where we need to paginate collections of
items. I''m trying to sort the collection and then pass it, sorted, to
a Paginator, and still be able to paginate through the collection,
across several pages, with the new sort order. The only thing I''m
doing differently from the regular scaffolding approach is this:
@order_pages = Paginator.new(self,
2006 Apr 24
5
Custom pagination
I am trying to paginate objects from a has_many/:through relationship
using Paginator.
current_user.things returns the objects that I''d like to paginate. For
testing, I tried to make it 1 item per page. I initialise the paginator
as follows:
@thing_pages = Paginator.new(self, current_user.things.count, 1,
@params[''page''])
I don''t know how to obtain
2005 Dec 19
6
custom find methods and pagination
i''ve got several methods in my models i use to find based on certain
criteria...i''ve done this so the controller code is less cluttered, plus the
DRY factor.
example:
class Foo < ActiveRecord::Base
def find_by_something(something)
find :all, :joins => ..., :conditions => ...
end
def find_by_something_else(something_else)
find :all, :joins => ...,
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 Apr 16
11
Best way to sort categories w/ pager
Ahoy,
I made this pager,
" def list
@item_pages = Paginator.new self, Item.count, 10, @params[''page'']
@items = Item.find :all, :conditions => "category_id =
#{params[:condition]}",
:limit => @item_pages.items_per_page,
:offset => @item_pages.current.offset
@categories = Category.find_all
2006 Apr 13
7
Complex SQL in paginate command?
Hi all,
Is there a way to create pagination with a complex SQL, more complex
than the :conditions option will support?
I have two databases, houses and images. Houses has_many images, and
each Image belongs_to house.
I''m creating a search engine for the house records and I''d like to be
able to filter out all the houses without any associated images.
So far I''m
2006 Aug 11
0
Paginating HABTM?
Is there an easy way to paginate HABTM? Something like (which doesn''t
work):
@pages, @directories = paginate :directories,
:include=>:categories,
:per_page=>ITEMS_PER_PAGE
directories and categories have an HABTM association.
Joe
--
Posted via http://www.ruby-forum.com/.
2006 Jul 19
0
Custom paginator?
I have the following query I need to paginate. Looks like I need a
custom paginator for this. Am I right?
SELECT full_name, address1, address2, city, state, zip,
abms_certification, X(geom) AS X, Y(geom) AS Y FROM physicians
where address_status = 1
and geom && Expand(GeometryFromText(''POINT(47.651443 -117.411025)'',4326),1)
AND