Ruby on rails 如何在没有Rails api版本的情况下设置api控制器

Ruby on rails 如何在没有Rails api版本的情况下设置api控制器,ruby-on-rails,api,ruby-on-rails-5,Ruby On Rails,Api,Ruby On Rails 5,我正在使用Rails 5创建API,但不能使用Rail 5 API only模式,因为我需要为用户身份验证设计。以下是我如何进行第一次API控制器设置: routes.rb /控制器/api_controller.rb 如何设置此功能?按如下方式设置控制器: # /controllers/api/v1/skills_controller.rb class Api::V1::SkillsController < ApplicationController # fill in the rest

我正在使用Rails 5创建API,但不能使用Rail 5 API only模式,因为我需要为用户身份验证设计。以下是我如何进行第一次API控制器设置:

routes.rb

/控制器/api_controller.rb


如何设置此功能?

按如下方式设置控制器:

# /controllers/api/v1/skills_controller.rb
class Api::V1::SkillsController < ApplicationController
# fill in the rest
end

你确定你没有在别处定义SkillsController?Ruby似乎希望它从另一个类继承。这也可能与重新加载或弹簧有关;一定要强迫他们停下来重新开始。谢谢你提到这一点。我刚检查过,SkillsController不在应用程序中的任何其他位置。
class ApiController < ActionController::API

end
class SkillsController < ApiController

  def index
    @skills = Skill.all
    json_response(@todos)
  end


  def json_response(object, status = :ok)
    render json: object, status: status
  end

end
I'm getting the following errors in the rails log:

Started GET "/api/v1/skills.json" for 127.0.0.1 at 2017-05-25 08:44:12 -0700
TypeError (superclass mismatch for class SkillsController):
app/controllers/api/v1/skills_controller.rb:1:in `<top (required)>'
Error during failsafe response: superclass mismatch for class SkillsController

ActionView::MissingTemplate (Missing template public/index.html with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :gzip], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}. Searched in:
# /controllers/api/v1/skills_controller.rb
class Api::V1::SkillsController < ApplicationController
# fill in the rest
end