2016-05-10 7 views
-1

Ich versuche, nur um die ID-Nummer selbst, anstatt das zu tun, so etwas zu einem bestimmten Datenbankelement zu verknüpfen:Wie nur durch ID-Nummer in Schienen link_to

<%= link_to locations_path(@location) do %> 
    <li class="border-top border-bottom">Location</li> 
<% end %> 

von Ich mag verlinkt die ID-Nummer manuell, etwas wie folgt aus:

<%= link_to locations_path(82) do %> 
    <li class="border-top border-bottom">Location</li> 
<% end %> 

Vielen Dank im Voraus!

+0

Es funktioniert nicht? Oder was? Es ist unklar für mich, was du fragst. –

+0

können Sie nicht nur 'locations_path (82)' verwenden? – PhilVarg

+0

Dies ist, was ich bekomme, http: // localhost: 3030/locations.82 statt http: // localhost: 3030/locations/82 – halfacreyum

Antwort

1

diesen Code Versuchen:

<%= link_to location_path(82) do %> 
        ^^^^^^^^^^^^^^ 
    <li class="border-top border-bottom">Location</li> 
<% end %> 
+0

Ich habe es vor ein paar Minuten herausgefunden, du hast recht, es muss einzigartig sein. Vielen Dank! – halfacreyum