그래서 저는 프로젝트에서 작업 중이며 새로운 하위 카테고리를 만들고 싶습니다. 링크가 작동했지만, 나는 다음과 같은 오류받지 못했습니다 :Ruby On Rails 라우팅 오류 (이전에 작동 했었습니다)
No route matches {:action=>"show", :controller=>"subcategories"}
이 프로젝트는 상당히 새로운 그래서 내 루트 파일은 매우 간단을 :
내보기에Mrprice::Application.routes.draw do
get "admin/index" => 'admin#index'
resources :products
resources :subcategories
resources :categories
root to: 'store#index', as: 'root'
end
:
<%= link_to 'New Subcategory', new_subcategory_path %>
어딘가에 오타가 있거나 그 해결책이 매우 간단하다고 생각하지만 나에게있어 그 삶을 이해할 수는 없습니다. 충분한 정보를 제공 했으므로 여기있는 사람이 문제가 무엇인지 알고 싶습니다.
편집 : subcategories_controller.rb (관련 방법)
def show
@subcategory = Subcategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @subcategory }
end
end
def new
@subcategory = Subcategory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @subcategory }
end
end
def create
@subcategory = Subcategory.new(params[:subcategory])
respond_to do |format|
if @subcategory.save
format.html { redirect_to @subcategory, notice: 'Subcategory was successfully created.' }
format.json { render json: @subcategory, status: :created, location: @subcategory }
else
format.html { render action: "new" }
format.json { render json: @subcategory.errors, status: :unprocessable_entity }
end
end
end
레이크 노선 제공 :
admin_index GET /admin/index(.:format) admin#index
products GET /products(.:format) products#index
POST /products(.:format) products#create
new_product GET /products/new(.:format) products#new
edit_product GET /products/:id/edit(.:format) products#edit
product GET /products/:id(.:format) products#show
PUT /products/:id(.:format) products#update
DELETE /products/:id(.:format) products#destroy
subcategories GET /subcategories(.:format) subcategories#index
POST /subcategories(.:format) subcategories#creat
new_subcategory GET /subcategories/new(.:format) subcategories#new
edit_subcategory GET /subcategories/:id/edit(.:format) subcategories#edit
subcategory GET /subcategories/:id(.:format) subcategories#show
PUT /subcategories/:id(.:format) subcategories#updat
DELETE /subcategories/:id(.:format) subcategories#destr
categories GET /categories(.:format) categories#index
POST /categories(.:format) categories#create
new_category GET /categories/new(.:format) categories#new
edit_category GET /categories/:id/edit(.:format) categories#edit
category GET /categories/:id(.:format) categories#show
PUT /categories/:id(.:format) categories#update
DELETE /categories/:id(.:format) categories#destroy
root / store#index
참고 : 서식을 수정하는 방법을 잘 - 나는 이미 코드 블록을 시도
show 경로에 문제가있는 경우 어딘가에서 ID가 누락됩니다. – apneadiving
오류가 가리키는 파일의 내용을 표시하십시오. –
새로운 하위 범주를 만들려고 할 때 왜 쇼 경로가 오류를 던지는 지 이해할 수 없습니다. 아무데도 내 시야에서 내가 쇼를 부를거야. 또한 프로젝트가 새롭고 하위 카테고리를 아직 만들지 않았기 때문에 어떤 ID도 없습니다. – SoSimple