Trying to order a list view

I’m trying to order a list view which contains elements from related
tables and wanting to use columns from the related tables to create the
order.

The error…

NoMethodError in Placements#list
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.facility

The code…

placements_controller.rb

def list
@client = Client.find(:all)
@facility = Facility.find(:all)
@placement_pages, @placements = paginate :placements, :order =>
@placements.facility.name, :per_page => 14
end

If I remove the :order => @placements.facility.name

I get the listing (unordered) with the facility.name column - no
problem. (facilies table is tied to placements table via foreign
keys/placements ‘belongs_to :facility’)

I want to be able to offer the list view ordered in different ways and
can’t figure out the entry to do that.

Thanks

Craig