我通過結果的收集迭代,而我在我的代碼有這樣link_to
:易Rails的LINK_TO
<%= link_to "", "#{expo.id}/edit" %>
我期望它去<domain>/exhibitions/3/edit
。 我已經在/exhibitions
頁面中,所以我就是從那裏得到的。問題是,它是去<domain>/exhibitions/3
並在那裏結束。出於某種原因,它不會在URL的edit
部分上標記。誰能幫忙?謝謝!
UPDATE
的代碼被包裹在此:
<% @exhibition.each do |expo| %>
<%= link_to "", expo_edit_path(:id) %>
<% end %>
更新2
我已經運行rake routes
,我確實有不正確的編輯路徑。現在的問題是網址。網址字面上變成:http://localhost:3000/exhibitions/id/edit
它字面上寫出id
這個詞。
這是我的新link_to
聲明:<%= link_to "", edit_exhibition_path(:id) %>
錯誤如下:
ActiveRecord::RecordNotFound in ExhibitionsController#edit Couldn't find Exhibition with 'id'=id
嗯,我認爲你的兩個部分現在編輯後不同步。 –