Forum: Ruby on Rails trying to order a list view

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-07 16:53
(Received via mailing list)
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
This topic is locked and can not be replied to.