【问题标题】:Missing template (jbuilder)缺少模板 (jbuilder)
【发布时间】:2016-06-04 17:20:56
【问题描述】:

Rails 试图找到包含 jbuilder 文件的用户文件夹,这些文件存在但不能

Application

Missing template users/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim, :coffee, :jbuilder]}. Searched in:
  * "/home/bjorn/Documents/poller/app/views"
  * "/usr/lib/ruby/gems/2.3.0/gems/devise_token_auth-0.1.37/app/views"
  * "/usr/lib/ruby/gems/2.3.0/gems/devise-4.0.3/app/views"

full error stack

# controllers/users_controller.rb
class UsersController < ApplicationController
  def index
    @users = User.all
  end

  def show
    @user = User.find(params[:id])
  end
end

# routes.rb
resources :users, only: [ :index, :show ]

【问题讨论】:

    标签: ruby-on-rails json jbuilder


    【解决方案1】:

    我克隆了您的存储库,但在 /api/users 没有收到此异常。

    但是,您需要将布局文件 application.slim 重命名为 application.html.slim。否则 jbuilder 也会渲染布局。

    【讨论】:

      猜你喜欢
      • 2017-12-24
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多