Displaying 20 results from an estimated 2000 matches similar to: "pagination over custom-sorted collections?"
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 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 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
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 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 Mar 28
3
coolest software ("coolest startups" re-asked)
Asked a little while back about "coolest startups" using Rails, I
think it''d have been better had I asked "coolest software." Besides
the obvious (37Signals, Typo, Yakima Herald, Odeo, Measure Map, etc.),
I''m just curious about other developments where people are using it to
make nifty stuff.
--
Giles Bowkett
www.gilesgoatboy.org
2006 Apr 22
2
put variable in session each time any controller runs?
Hi -- well, that''s what I''m trying to do. Does anyone know what the
best way to do it is? I have three controllers, each one has a hidden
tag, and I want each one to salt its respective tag with the name of
the action in effect, at the time that action runs, for every action
in the controller.
--
Giles Bowkett
http://www.gilesgoatboy.org
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 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
2008 Mar 01
5
rspec with continuations: very strange
I appear to have written code which travels backwards through time:
http://www.vimeo.com/742590
This disturbs me immensely. If anyone can explain it, that would be cool.
I think it''s an illusion brought about by how RSpec wraps the code it
executes, and by the sheer weirdness of continuations.
--
Giles Bowkett
Blog: http://gilesbowkett.blogspot.com
Portfolio:
2008 Jan 17
5
unusual challenges speccing external software
This is something I''ve come up against twice. First, I have an
interactive editor which calls vi, emacs, or TextMate (etc.) via Unix,
and then loads the file handed to the editor back into IRB after it''s
edited and saved. I guess that makes it a special case of a more
general question, which is how do you spec external processes, with a
slightly more complicated version of the
2007 Jul 01
1
how many Mongrels?
Hi - I''ve got a pretty popular Rails app on a Mongrel cluster with
Apache and mod_proxy_balancer. How do I decide how many Mongrel
servers to put in the cluster?
I don''t have stats for the number of requests hitting the server yet,
but I should have that data soon. The server has 2GB of RAM and has to
do a lot of work with RMagick, including generating and storing lots
of
2006 Jul 27
1
form_tag vs form_remote_tag ----- the :condition option
form_remote_tag has a really useful little thingamob called
:condition. you give it a string which is then interpolated into the
form tag in such a way that the form is only submitted if :condition
evaluates in javascript to true.
so the logical thing to do is give it a JavaScript function
<%= form_remote_tag ( :condition => ''your_function_here()'',
2006 Apr 27
10
OT -- billing and estimating, good resources?
OK, so for most of my career, I''ve done everything on an hourly rate.
Recently somebody kind of pointed out that if you bill by the
milestone you can work on multiple projects simultaneously without any
ethical problems, so you get increased efficiency. Does anyone have
any good advice/URLs/books on how to do cost estimates on a project?
I''ve really always kind of avoided the
2008 Jan 04
7
best way to modify spec (the command-line tool)?
Hi all, where I work we''ve cooked up a kind of ghetto profiler for our
specs. It basically just does this:
time = Time.now
# run the spec
puts "woah! dude. long spec." if time > 1.second
I''m simplifying here. I think the threshold is actually 0.1 seconds,
and we use more precise language, and highlight the spec in red via
terminal colors, etc.
But the way it works
2007 Dec 29
5
./script/story command
Below I''ve pasted a ./script/story command I''ve been using for about a
week. It has three modes of operation:
1. ./script/story with no arguments will run all *.story files in the story path
2. ./script/story with a path or glob will run the specified stories
3. If input is passed in via STDIN, it runs that text as a story. This
opens up story running via a simple interface
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 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) *
2008 Jan 26
6
UI Integration with RSpec?
Hi all,
Is there any integration with testing tools such as RSpec or
Test::Unit planned? I see that the cruise task is run correctly, but
the tests show up underneath the build log. Ideally I''d like them to
show up the same way that they do in ''java'' CruiseControl, in their
own section of tests.
Will.
2006 May 04
5
I''m writing an article about Rails and I need help
Hi to everybody, I''m writing an article about Ruby on Rails and I need
to gather some information about the project and the community of core
developers. In particular I''d like to know something about the
organization of the project (how are decisions taken, who decides what
goes into the project, conflict resolution, contributions acceptance...)
and something more technical