similar to: custom find methods and pagination

Displaying 20 results from an estimated 2000 matches similar to: "custom find methods and pagination"

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 =
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 Jun 07
1
Reverse engineering pagination and more
Hey all, I''m building a photo album site (for fun) and have a few questions. 1) This site will have a browse section, where you can view the photos by thumbnail. I want to let the user change how many thumbs they can see per page. I''ll have a couple links at the bottom of the page letting them do that. The problem is, if they are in the middle of browsing and decide to
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 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 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 16
13
How to pass a collection to paginate?
There must be a better way to write this code: @project_pages, @projects= paginate :project, :per_page => 10, :conditions => ["account_id = ?", account] ?! If only I could pass the sub-collection account = ... @projects = account.project to paginate, instead of letting it extract it with a find :all + sql conditions Alain. -- Posted via
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 Feb 23
6
Search Forms with Pagination
Hi there everyone, I''ve recently moved to RoR and am still struggling with the basics of what used to be second nature in php, so on with my question: I have a database with products, and I need to create a search form that paginates the results. What I have so far in my controller is: def list # If the values are nil, then set them, otherwise wrap them in % # Also,
2006 Aug 03
5
Strategy for persisting row filter variables in pagination?
I have my list view filtering rows shown within the table <tr> tags like most of the introductory tutorials do. As I''m adding a few dozen entries I''m noticing the standard scaffolding pagination doesn''t pick up the number of rows from the filter since it is not being passed the number of rows returned within the scope of the filter statement. >From a
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
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]
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 Mar 31
4
Question about pagination
Hi! I''ve got a list of project on the main page and if one of them is selected i render a partial using ajax with data of selected project. How to create links to next/previous project using pagination? -- Posted via http://www.ruby-forum.com/.
2006 Apr 18
1
Pagination links with separator
Hi, I have @result_pages and @results obtained from paginate in an action. I want to show the pages as 1 | 2 | 3 | 4 > The fifth page will show: < 5 | 6 | 7 | 8 > and so on. How exactly do I render the paginator to give this effect? I guess I will have to use pagination_links_each. But being new to Rails, I need help. Thanks, Yash -- Posted via http://www.ruby-forum.com/.
2006 Jul 31
1
Pagination of Complex Queries
I''ve created a class method in my model called find_filtered. The intent is that I take various params that the user has submitted, and let the model build the query and return the AR collection, which is exactly what happens. However, now I''d like to paginate the recordset. Everything I''ve been able to find about pagination presumes that you have no pre-existing AR
2006 Feb 13
1
Paginate @member.items?
Is there a quick and easy way to paginate something like @member.items (Member with has_many :items)? Right now I do in the controller: @item_pages, @member_items = paginate :item, :conditions=>["member_id=?", @member.id], :per_page=>25, :order=>''datetime desc'' It''d be more DRY if this was possible: @item_pages, @member_items = paginate
2006 May 01
12
pagination in acts_as_ferret
I''m just wondering where I would put the pagination for search results when using "acts_as_ferret". At the moment my search code is.. def search @query = params[:query] || '''' unless @query.blank? @results = Tutorial.find_by_contents @query end end Cheers SchmakO -- Posted via http://www.ruby-forum.com/.