我想用不同的
.erb
文件而不是默认值
application.erb
,我按照它在
https://guides.rubyonrails.org/layouts_and_rendering.html#finding-layouts
我在routes.rb中创建了一条路线
get "/vue/v1/" => "vue#vue"
控制器作为
vue_controller.rb
它的内容是
class VueController < ApplicationController
layout "vue"
def vue
end
end
在我的
view/layouts/
,我还创建了一个文件作为
vue.html.erb
以便控制器可以使用它。内容
Vu.HTML.Erb
一样简单
<%= javascript_pack_tag 'application' %>
但是每当我去
"/vue/v1/"
它只给了我错误
VueController#vue is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.