Ruby On Rails API-Only 模式使用 jbuilder
环境
-
rails 6.0
-
ruby 2.6.5
步骤
-
打开
Gemfile
找到# gem 'jbuilder', '~> 2.7'
,取消掉这行的注释 -
执行
bundle install
-
打开
app/controller/application_controlle.rb
文件,在ApplicationController
类中加入两行
class ApplicationController < ActionController::API
include ActionController::ImplicitRender # 新加的
include ActionView::Layouts # 新加的
end
-
重启
rails s
即可
评论