search for: order_by

Displaying 20 results from an estimated 54 matches for "order_by".

2006 Feb 07
11
breaking down a list view
I''m trying to figure out how to change the order of a list view and it''s obvious to me that I don''t understand what I get from a simple scaffold to know enough to alter it. If someone would be so kind to tell me what this means ... def list @placment_pages, @placements = paginate :placements, :per_page => 10 end @placement_pages, # I am guessing that this
2006 Feb 08
7
DRY methodology
...t my ''list''...is there a logical way of not repeating myself to having essentially the same list view with multiple sorts? i.e. def list_cl # ordered by clients last name @placement_pages, @placements = paginate( :placements, :include => [:client], :order_by => ''clients.last_name'', :per_page => 14) end def list_fac # ordered by facility @placement_pages, @placements = paginate( :placements, :include => [:facility], :order_by => ''facilities.name'', :per_page => 1...
2006 Jun 14
4
Using now() to determine what should be displayed
I''m trying to create a paginated list that will take note of the "end_date" field in my table. This is what I have: @post_pages, @posts = paginate(:posts, :per_page => 10, :order_by => ''end_date'') in the controller. And for the view: <h1>Posts ending soon</h1> <ul><% for post in @posts do %> <strong>Post Title: </strong><%= post.title %> <strong> Date Ending: </strong><%= post.end_date %>...
2006 Aug 07
4
Problem with Pagination
...inate (:k2_results, :conditions => [''e_date >= ? AND e_date <= ?'', ''2006-07-12'', ''2006-08-12''], :per_page => 5, :order_by => ''e_date,name'') end However, if I change it to use the POST parameters in the conditions instead, the pagination fails. It correctly shows that I have 14 records and also shows that there are 3 pages, but when I click on "next page", it gives me an error saying...
2006 May 14
4
searching on foreing keys
...me,owner_id) and another table people(id,name) owner_id being a foreign key of pet pointing to people name. here it is on the pet controller: @paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id like ?","%"+params[:filter]+"%"], :include =>person,:order_by => @sort_by,:per_page => default_per_page ) it searches great in name but not in owner_id. I mean it searches through people id instead of the person name it''s referring. Any idea how to make it search through the foreign key? thanx in advance Pat
2006 May 23
1
Re: Wierd pagination problem - Unknown options:
...commented line works): > > def list > @upload_pages, @uploads = paginate(:uploads, :per_page => > 20, :order > => ''id'') > # @upload_pages, @uploads = paginate(:uploads, :per_page => 20) > end You may have an older version, try using the order_by clause @upload_pages, @uploads = paginate(:uploads, :per_page => 20, :order_by => ''id'') If that works get the latest version, order_by is deprecated. Bharat
2006 Mar 31
2
Silly question
Hi there, I know this is be a very minor issue, but considering @users = User.find :all, :order => ''name'' _AND_ @user_pages, @users = paginate :user, :order_by => ''name'' by simplicity, shouldn''t the symbols :order and :order_by be the same or both to both cases ? I stumbled on them a couple of times yet :) Thanks, Andre -- Posted via http://www.ruby-forum.com/.
2006 Feb 14
1
How can I order_by a sub folder?
Hi there! I have a folder model which can contain sub-folders. I want to save the sub-folders in a variable ordered by the name of the subfolders: folder = Folder.find(1) sub_folders = folder.folders # ... how can I order the sub folders by name here??? Thanks, Mischa.
2006 Apr 16
7
table sorting
Ahoy, I checked the API and did some forum searches but didn''t find anything good on table sorting. Is there a "railish" way to do this? My current method really is lacking (i''m on like rails day 2) <th><%= link_to ''Name'', :action => ''list'', :order => ''name'' %></th>
2006 Aug 02
3
newbie question, adding conditions to collection of sql objs
I have: @pictures=@c.pictures How do I add limit and order_by conditions. I have tried the following: @c.pictures.find_all(:limit=>5) @c.pictures, :limit=>5 @c.pictures :limit=>5 None of these work. -- Posted via http://www.ruby-forum.com/.
2005 Dec 31
3
Sort or Order a <Select> box.
...; <%= '' selected'' if peoplekind.id == @people.peoplekind_id %>> <%= peoplekind.name %> </option> <% end %> </select></p> <input type="submit" value="Update" /> In the controller for the List page I am able to use, :order_by => ''name'' , under the Def List. I have tried this in <% @peoplekinds.each do |peoplekind| %> above, but this does not work. How far off track am I? Kindest regards. -- Posted via http://www.ruby-forum.com/.
2006 Apr 10
9
Pagination with letter (A B C D ... Z)
Hi there, Is there a neat and easy way to implement pagination with letters rather than numbers eg : A B C D ... Z Rob
2006 Jun 08
9
find :order =>
Hi, I have the following find statment @client_pages, @clients = paginate :clients, :per_page => 20, :order => "organisation_id, surname" currently im ordering by organisation_id however I need to order by the field in the organisation table organisations.name how can this be done? Thanks Scott -- Posted via http://www.ruby-forum.com/.
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 10
0
Rails form error message oddness...
...------------------- class ClientsController < ApplicationController #---- index -------------------------------- def index list render :action => ''list'' end #---- list -------------------------------- def list @client_pages, @clients = paginate(:clients, :order_by => ''name'') end #---- new client -------------------------------- def new #raise params.inspect @client = Client.new(@params[:client]) if request.post? && @client.save flash[''notice''] = ''Client created successfully'...
2006 Apr 26
2
two layers of has_many
...pany < ActiveRecord::Base has_many :departments def employees Employee.find_by_sql("SELECT employees.* FROM companies, departments, employees WHERE companies.id=departments.company_id AND departments.id = employees.department_id" ORDER_BY employees.last_name) end end class Department < ActiveRecord::Base belongs_to :company has_many :employees end class Employee < ActiveRecord::Base belongs_to :department end I am using Rails 1.0 if that matters. Does it matter? Does the new has_many :through work here? Thanks, P...
2006 Mar 30
6
MS SQL query strangeness for ActiveRecord in Rails
Hi, I am currently trying to move my rubyonrails app from Linux to Windows server utilizing MS SQL instead of MySQL due to "business" reason. All my listing screen utilize a drop down list in each column to allow user to "filter" the listing based upon the value chosen from the drop down list. In the controller, I used find() method but with customized parameters such as
2006 Aug 17
8
Creating queries..
Hi, I am trying to implement a few queries now. What are good ways to do this? Right now, I have a list page that does sorting and can carry out a generic pagination request. @user_result_pages, @user_results = paginate(:user_results, :per_page => 20, :conditions => @condition, :order_by => @sort_order) I create @sort_order earlier in the list function. The problem I am having is with ''@condition'' I''m not sure what''s the best way to create this. There are a number of options that my user may select: 1. date > ... 2. range of dates 3. spe...
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 Jan 24
4
How to filter an activerecord find_all...
I have a nice hierarchical table structure like this: divisions has_many groups groups belongs_to division has_many subgroups subgroups belongs_to group has_many units units belongs_to subgroup I have a report which is based on units, but i want to be able to filter the units by which subgroup, or which group, or which division. I also want to sort them by division.name,then group.name,