similar to: Complex SQL in paginate command?

Displaying 20 results from an estimated 4000 matches similar to: "Complex SQL in paginate command?"

2006 Feb 21
6
Select articles from group with id ''1'' and id ''2''
I have to tables: "articles" and "groups". Between I have article_groups as a jointable. Now I want to select every article who is a member of group with id ''1'' and id ''2''. Whats best way to get that? Extract from schemas: CREATE TABLE articles ( id int auto_increment, ingress text NOT NULL, story_text longtext, constraint fk_items_users
2006 Aug 14
5
Tutorial for Queries
Hi! I''m looking for a good tutorial that explains the main points of performing queries with Rails. I do have AWDWR and have read the section on ''find'' but I''m looking for something that goes into more detail on how to perform queries across tables. Abstracted from my current application, this is an example: * person has_many sites * site has_one room *
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 Feb 08
2
What page is an item on?
Using the paginator helper, is there a way to determine what page an item in the collection is on? Thanks in advance for your help!
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 03
5
Pagination Question
Hi - I''ve just started working with Rails, having come from a Cold Fusion background. I''m curious how best to deal with a huge result set. For example, I''m building an app that contains users. I''ve used scaffolding to setup my initial pages for CRUD operations on users. All that is great. The problem is, I''m going to end up with 1000+ users in
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 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 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 Jan 03
2
Scaffolding - changing number of records per page
People, This is probably simple but I couldn''t find where to change the default 10 records per page for scaffolding . . Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Mobile: +61:(0)411-185-652 Fax: +61:(0)2-8221-9599 E-mail: phil@pricom.com.au
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 Aug 04
8
I need an idea !
Hello here, I need to find an idea to solve a problem I manage Events which are of kind :arrival or :departure At first the two kind of events was unrelated but my client want to see the :departure belonging to the :arrival and vice versa. I''m searching for a solution to implement this ''link''. I''ve thought about an integer column containing an uniq id for
2006 Jul 29
3
Engines question
I would like to get at all models in a rails application to be able to add a field to every one of them as part of a migration. Something like the following: Appmodels.each { |x| add_column x.table_name.to_s, :foo, :text } I understand I can get the table name using ActiveRecord::Base#table_name, but how do I get all the models into an array that I can use in the above manner? -- Cheers, Hasan
2006 Jan 18
2
Migration?
I just installed ruby, lighttpd, and mysql from darwinports on me laptop in lieu of the Apple version of ruby. Now when I fire up my rails application, it''s not running lighttpd anymore -- it''s running webrick. It also exits immediately. MySQL is running, the database and tables are restored from the backup. What step am I missing? Thanks for the help! Cheers, Hasan
2006 Aug 13
3
escape block using red cloth
Hi all, Is it possible to configure red cloth to escape a block such as: ------------------------------------------------------------------ Hello, _this_ works *beautifull* [code lang="ruby"] def foo bar end [/code] ------------------------------------------------------------------ The text in the [code] block should not be parsed by Red Cloth''s to_html method. I cannot
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 02
5
How to use MySQL sum() to get total of column?
Easy one: Let''s say I have a table called ''employees'' with a column called salaries, how can I add Employee.salaries_total to the model? Thanks! -- Posted via http://www.ruby-forum.com/.
2006 Feb 01
2
Uninitialized constant ApplicationController?
Hello list, I''m trying to start my Rails server after doing a long complex switch from Postgres to MySQL, and I''m getting the following error: => Booting WEBrick... /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in `const_missing'': uninitialized constant ApplicationController (NameError) from
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
2005 Dec 14
3
Geocode for Ruby
Hey, Does anybody know of a good Geocode library for Ruby, similar to Perl''s Geocode::Postal, that i could use in my rail app? I need to do some "within 5 miles" calculations of zipcodes and i dont have a nice ruby (or gem) utility to do it. any help would be appreciated. thanks adam _______________________________________________ Rails mailing list