Hi,

give this a try. Not sure it will work, haven't tested it at all, but it
might.

class User
has_many :update_requests
has_many :contacts, :through => :update_requests, :order => 'last_name'
end

-Tim

On Tue, Nov 17, 2009 at 5:14 PM, lunaclaire <[email protected]> wrote:

>
> Yes, in a browser.
>
> It's a page where I list these UpdateRequests showing, amongst other
> things, the name of the Contact for whom the UpdateRequest has been
> created. And I'd like to be able to have that list of UpdateRequests
> sorted on the Contact's last_name.
>
> But, this is really also a general question about how to sort on (and
> how to get at) the attributes of an associated object from a object
> that joins objects (note that that's what an UpdateRequest does for me
> here).
>
> On Nov 16, 7:36 pm, Conrad Taylor <[email protected]> wrote:
> > On Mon, Nov 16, 2009 at 7:02 PM, lunaclaire <[email protected]> wrote:
> >
> > > here are my models (only showing the associations that relate to this
> > > post):
> >
> > > class UpdateRequest < ActiveRecord::Base
> > >        belongs_to      :user
> > >        belongs_to      :contact
> > > end
> >
> > > class User < ActiveRecord::Base
> > >        has_many        :update_requests, :dependent => :destroy
> > > end
> >
> > > so I want to be able to list UpdateRequests and sort them based on
> > > attributes of the referenced Contact in each
> >
> > > I cant, for instance, do the following for the User
> >
> > >       has_many :update_requests, :dependent => :destroy, :order =>
> > > 'contacts.last_name asc'
> >
> > > It doesnt know about the 'contacts' table's columns
> >
> > > I can do this, right? How?
> >
> > > Thx
> >
> > How is this to be use?  For example, are  you displaying this information
> to
> > the user within the
> > browser?
> >
> > -Conrad
> >
> >
> >
>


-- 
Tim Harding

Muriwai Technologies Ltd
Registered in England & Wales
Company number 5800651
Registered office: 2 Church St, Burnham, Bucks, SL1 7HZ

Well Informed Ltd
Registered in England & Wales
Company number 06707839
Registered office: Suite 235, 77 Beak St, London, W1F 9DB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to