similar to: moving pagination code to model

Displaying 20 results from an estimated 800 matches similar to: "moving pagination code to model"

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]
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
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 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 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
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 Apr 23
0
Using Paginator outside of controllers
I am doing this in _messages.rthml: <% shout_pages = Paginator.new self, Shout.length, 30, @params[''page''] %> <% shouts = Shout.find :all, :order => "timestamp desc", :limit => @story_pages.items_per_page, :offset => @story_pages.current.offset %> I am calling
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
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 =>
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) *
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
2008 Sep 25
1
question about exception
Hi In the controller I have the function def convert_sd_ticket_to_incident ServiceDeskTicket.close_ticket(sd_id,created_by_id,modified_by_id) Incident.convert_sd_ticket_to_incident(sd_id,created_by_id,modified_by_id) end Now in the ServiceDeskTicket model def self.close_ticket(sd_id,created_by,modified_by) begin ActiveRecord::Base.transaction do
2008 Jun 16
2
call_backs Is it?
Hi I have the models 1.ServiceDeskTicket with fields id --- number --- service_desk_status_id -- created_on -- updated_on etc 2.ServiceDeskActivity with fields id -- service_desk_ticket_id -- description -- created_on -- updated_on 3.ServiceDeskAttachment id -- service_desk_ticket_id -- attachment -- created_on -- updated_on Relations as ServiceDeskticket has_many
2006 Dec 11
2
Switch and integer
I searched the help list and the manual, but I do not find my mistake. Switch is working with character , with integer, but not in the third example Regards Knut count1 <- 0 test
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
2010 Feb 18
1
an error about " return some vectors from some functions within a function"
Dear all, When I try to return some vectors from some functions within a function, it indicate an error," Error in rbind(ck1, ck2, ck3) : object 'ck1' not found", in one of the iterations and stop.  Since I am not experienced in programming, can anyone give me a suggestion to inspect this error? The followings are the functions I created : ################### # functions in the
2012 Jul 11
3
Subset based on multiple values
I'm stuck on a seemingly simple problem. I'm trying to subset the data by several numbers and it cuts out half of the rows. Here is the sample code: test <- as.matrix(c(1,1,1,1,3,3,7,7,7,7)) Count <- tapply(test[,1], test[,1], length) # count for each value spp <- unique(test[,1]) Count1 <- as.data.frame(cbind(Count,spp)) Max <- max(Count) Count1$sppMax <-