Select dropdown based off join table's include?

I have a "New Photo" view where I'd like to provide a select dropdown of the user's favorite locations. Getting the data for a user's favorites is no problem, but I'm not sure how to put the location name into the select form.

def new   @photo = Photo.new   @favorites = current_user.favorites.find(:all, :include => :location) end

<%= f.collection_select :location_id, @favorites, :location_id, :location_id, { :include_blank => true }, {} %>

(the 4th parameter in the f.collection_select above is my problem)

On a related note, is there a more efficient way to query for the locations' id & name w/o returning all fields? Or is it not really that much of a performance issue?

Any tips would be greatly appreciated. Thanks in advance.

Add location_name as a method on User:

  def location_name     self.location.name   end

Then you can pass :location_name to collection_select.

Ciao, Sheldon.