[英]rails RESTful routing with Devise not working
使用Devise 3.0和Rails 4.0
我似乎無法正常使用安靜的路線。
當我訪問URL / products /或URL / products / 3460 (以查看特定產品的“顯示”操作)時,分別出現以下錯誤:
Missing Template
Missing template products/show, application/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}.
Products_controller.rb
class ProductsController < ApplicationController
def index
@products = Product.all
end
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @product }
end
end
我在app / views / product中也有index.html.erb和show.html.erb視圖文件
耙路輸出:
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
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
PATCH /products/:id(.:format) products#update
PUT /products/:id(.:format) products#update
DELETE /products/:id(.:format) products#destroy
root GET / application#index
GET /products(.:format) products#index
login GET /login(.:format) devise/sessions#new
logout DELETE /logout(.:format) devise/sessions#destroy
有人看到我很想念的東西嗎?
show.html.erb
視圖文件必須存在於app/views/products
目錄中。
注意 products
(復數)而不是product
(單數)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.