前段时间我在API模式下启动了一个Rails 5项目,但我现在想让应用程序也开始渲染html并提供资源。
这就是我application.rb
现在的样子:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module AppName
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
end
请注意,api_mode
已不再提及。
但是,当我尝试运行服务器时,我收到以下错误:
/home/username/Sites/oneroster/app/controllers/application_controller.rb:8:in `<class:ApplicationController>': undefined method `helper_method' for ApplicationController:Class (NoMethodError)
from /home/username/Sites/oneroster/app/controllers/application_controller.rb:1:in `<top (required)>'
我还应该做些什么来让应用再次运作?
答案 0 :(得分:0)
在application_controller.rb
我有
class ApplicationController < ActionController::API
必须改为:
class ApplicationController < ActionController::Base