简体   繁体   English

使用Devise的Rails RESTful路由不起作用

[英]rails RESTful routing with Devise not working

Using Devise 3.0 and Rails 4.0 使用Devise 3.0和Rails 4.0

I can't seem to get my normal restful routes working. 我似乎无法正常使用安静的路线。

When I visit URL/products/ or URL/products/3460 (to view the "show" action of a specific product) I'm given the following error respectively: 当我访问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 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 

I also have index.html.erb and show.html.erb views files in app/views/product 我在app / views / product中也有index.html.erb和show.html.erb视图文件

rake routes output: 耙路输出:

      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

Anyone see anything obvious I'm missing? 有人看到我很想念的东西吗?

show.html.erb view file must be present in app/views/products directory. show.html.erb视图文件必须存在于app/views/products目录中。

Note products (plural) and not product (singular). 注意 products (复数)而不是product (单数)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM