Wie konvertiere ich dieses Dropdown in ein f.select in Rails?

Ich bin ein Rails-Anfänger und arbeite an einem bereits existierenden Rails 2-Projekt. In meiner Anwendung habe ich versucht, ein Dropdown-Feld select in einen form_handler f.select zu konvertieren, es wird jedoch der folgende Fehler angezeigt:

    undefined method `location.masterlocation.name

Hier ist mein Versuch:

    <% form_for @newsavedmap, :html=>{:id=>'createaMap'} do |f| %>

    <%= f.select(:start, options_from_collection_for_select(@itinerary.locations, "location.masterlocation.street_address, location.masterlocation.city, location.masterlocation.state, location.masterlocation.zip", "location.masterlocation.name"), :id => "startdrop")%>

Hier ist das ursprüngliche Dropdown-Feld:

    <select id="startdrop">
    <option value="">
    <% for location in @itinerary.locations %>
    <option value="<%= location.masterlocation.street_address %> <%= location.masterlocation.city %>, <%= location.masterlocation.state %>, <%= location.masterlocation.zip %>"><%= location.masterlocation.name %></option>
    <% end %>
    </select>

Vielen Dank im Voraus für Ihre Hilfe!

bearbeiten 1

Ich bin mit diesem Code viel näher gekommen:

    <%= f.select :start, options_for_select(@itinerary.locations.map{ |c| [c.masterlocation.name, c.masterlocation.street_address]}),{}, :id=>"startdrop", :name=>"startthere" %>     

Das Problem ist, dass ich die Stadt, das Bundesland und die Postleitzahl in den Wert aufnehmen möchte, die alle durch Kommas getrennt sind. Irgendwelche Ideen dazu?

    <%= f.select :start, options_for_select(@itinerary.locations.map{ |c| [c.masterlocation.inst_name, c.masterlocation.street_address AND , AND c.masterlocation.city AND , AND c.masterlocation.state AND, AND c.masterlocation.zip]}),{}, :id=>"startdrop", :name=>"startthere" %>     

DAS FUNKTIONIERT!

Maptry Helper:

    module MaptryHelper

def options_for_select(locations)
  locations.map do |location|
    [location.masterlocation.name, location_string(location.masterlocation)]
  end
end

def location_string(masterlocation)
  "#{masterlocation.street_address}, #{masterlocation.city}, #{masterlocation.state}, #{masterlocation.zip}"
end

    end 

Aussicht

    <%= f.select :start, options_for_select(@itinerary.locations),{}, :id=>"startdrop", :name=>"startthere" %>     

Antworten auf die Frage(1)

Ihre Antwort auf die Frage