저는 지난 며칠 동안 기본적인 레스토랑 웹 사이트를 만들려고 애 쓰고 있습니다. 웹 사이트에는 여러 레스토랑이 나열되며 각 레스토랑에는 메뉴가 있습니다. 지금은식당에 메뉴를 연결하려고 할 때 오류가 발생합니다.
내 메뉴 협회
class Menu < ActiveRecord::Base
belongs_to :store
end
class Store < ActiveRecord::Base
has_one :menu
end
내 경로는 다음과 같습니다
Rails.application.routes.draw do
resources :stores do
resources :menus
end
root 'stores#index'
내가 상점에 대한 참조를 추가 마이그레이션을했다. 이 문제는 레스토랑 쇼 페이지에 새 메뉴를 추가하기 위해 link_to 버튼을 만들려고 할 때 발생합니다.
<%= link_to 'Create menu', new_store_menu_path %>
나는 모든 show.html.erb
No route matches {:action=>"new", :controller=>"menus", :id=>"1"} missing required keys: [:store_id]
에게
감사를로드 할 때이 나에게 오류를 제공합니다!
당신이 당신의 메뉴 컨트롤러를 게시 할 수 있습니다에있는
store_id
이 missing.Make가 확실 제안? –내 대답이 도움이 되었습니까? – Pavan