我是一個新手到鐵路,並嘗試建立我的第一個網站,但面臨一個索引頁面link_to問題。鏈接重定向到/recipes.1而不是/ recipes/1。 當我嘗試/食譜/ 1時,顯示頁面工作。問題link_to在索引
Index.html.erb
<% provide(:title, "Recipe") %>
<% @recipes.each do |recipe| %>
<%= link_to recipe.label, recipe%>
<%end%>
route.db
get 'recipe' => 'recipes#show'
get 'recipe' => 'recipes#new'
post 'recipe' => 'recipes#create'
resources :users
resources :recipes
recipes_controller.rb
def index
@recipes = Recipe.all
end
def show
@recipe = Recipe.find(params[:id])
end
謝謝,這是問題,我已經刪除它們,它的工作。 –
很高興它解決了你的問題! – dp7