Displaying 20 results from an estimated 50000 matches similar to: ":select option with paginate / count"
2005 Dec 10
0
Paginate - Count(*) Broken or Am I Cheating?
I have the following paginator setup:
@merch_pages, @merch = paginate :merch_item, :per_page => 15, :select =>
''DISTINCT mi.id, mi.merch_image, mi.created_at, mi.artist_id,
mi.item_description, art.sort_name'', :join => ''as mi JOIN merch_formats mf
ON mi.id = mf.merch_item_id JOIN artists art ON mi.artist_id = art.id'',
:order =>
2005 Dec 29
4
Paginate do a Count(*) request before, how access that count value.
Hello,
AV::paginate query first by a count, how access this value in the
controller or view ?
Why ?
Because I''ll like to display the total number or records found w/o
doing another expenssive Count.
Thanks,
2005 Dec 29
1
Paginate do a Count(*) request before...
Mathieu,
Paginate needs to know how many total records there are when you
create the object so you must either do an SQL COUNT or get all the
records and find the length of the array. If it''s a small data set,
I say find them all once and save yourself the second SQL query. If
it''s a large data set do the COUNT and then only find the records you
want which will save
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
2007 Apr 04
2
[PLUGIN] ArPaginator - Allows you to easily paginate over any existing AR queries.
The built-in Rails pagination is fairly limited...you pass in the
model name, and optionally some conditions, and it generates a
paginated query for you. This gets to be very bad if you''ve got any
custom queries.
class Company < ActiveRecord::Base
def complete_videos
Video.find :all, :conditions => "company_id=#{id} AND
status=''complete''", :order
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 => ...,
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 Jan 06
2
Paginate from a difficult sql query
Hello,
I have 2 tables
table colors :
+----------------------+
| id | user_id | name |
+----------------------+
| 1 | 1 | test1 |
| 2 | 2 | test2 |
| 3 | 3 | test3 |
+----------------------+
table users :
+----------------------+
| id | enabled | name |
+----------------------+
| 1 | 1 | bob |
| 2 | 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 =>
2005 Apr 10
1
Submitting form using link_to
I''ve got a form with a paginator and I''d like to save the contents of the
form whenever the user moves to a different page. Since the form contents
aren''t submitted when a link is clicked, I thought I''d just change the
action of the form to the URL of the paginator link and then submit the form
using form.submit().
The form submits but I keep getting a 404
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,
2007 Jan 03
1
Added :group option to paginate method
Ok, nothing really difficult, I add the possibility to call the
paginate method
with the :group option.
Please, someone can tell me how to submit this patch?
Thanks
Sandro, sandro@railsonwave.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send
2005 Dec 20
7
wrong id for activerecord object when using :joins in mysql
I''m using a find with a :joins clause, like this:
:joins => "JOIN table_b ON table_b.id=table_b_id"
The records returned are used in a scaffold generated list page. The edit,
show, and destroy links are getting the wrong id. They are getting the id of
the table b record.
When I run the query using mysql, I see that the query returns *2* id
columns, the id of the main
2006 Mar 27
0
no :group option in paginate helper?
I need to use :group in my paginate helper,
but it seems not to support this option?
2006 Mar 16
3
How to paginate in descending order?
How can I paginate a set of fields in descending order based on their
created_on date?
For example, in a blog app, you want the very first entry on the first
page to be the most recent.
I see that paginate has an :order parameter, but I don''t see any way of
changing the direction of the order.
Thanks,
Jeff Coleman
--
Posted via http://www.ruby-forum.com/.
2006 Aug 02
2
Ajax_Scaffold display from link table
Hi,
Ive followed the pets/people ajax_scaffold example without any problem.
I have a table documents and each document has a category. In the
documents table i have a field called category_id. So in the documents
grif i want to display the corresponding catgory name and when it comes
to adding a new category or editing the have a drop down list to select
from.
category.rb
require
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 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 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 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/.