错误:ActionView :: MissingTemplate(在迁移到rails 5后缺少模板应用程序/索引,具有>]

问题描述 投票:0回答:1

我已将我的Web应用程序从ruby 2.1和Rails 4.0迁移到ruby 2.4.9p362和rails Rails 5.2.4。

尝试登录之前,它可以很好地工作,但是在迁移之后,我会收到下一条错误消息:

Started OPTIONS "//login" for 127.0.0.1 at 2019-11-29 11:47:06 +0100
Processing by ApplicationController#index as */*
Completed 500 Internal Server Error in 24ms (ActiveRecord: 0.0ms)



ActionView::MissingTemplate (Missing template application/index with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :vtt, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :mp3, :ogg, :m4a, :webm, :mp4, :otf, :ttf, :woff, :woff2, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :gzip], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}. Searched in:
  * "/Users/Rober/Projects/yanpy/dev/yanpyapi/app/views"
):

app/controllers/application_controller.rb:12:in `index'

这是我的application_controller:

class ApplicationController < ActionController::Base

  before_action :set_headers

  def index

    render nothing: true
  end

  def set_headers

    if request.headers["HTTP_ORIGIN"]     

    # better way check origin
    # if request.headers["HTTP_ORIGIN"] && /^https?:\/\/(.*)\.some\.site\.com$/i.match(request.headers["HTTP_ORIGIN"])
      headers['Access-Control-Allow-Origin'] = request.headers["HTTP_ORIGIN"]
      headers['Access-Control-Expose-Headers'] = 'ETag'
      headers['Access-Control-Allow-Methods'] = 'GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD'
      headers['Access-Control-Allow-Headers'] = '*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token'
      headers['Access-Control-Max-Age'] = '86400'
      headers['Access-Control-Allow-Credentials'] = 'true'
    end
  end
  #def set_csrf_cookie_for_ng
  #  cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
  #end

#protected

 # def verified_request?
 #   super || form_authenticity_token == request.headers['X_XSRF_TOKEN']
 # end  
end

我猜想新版本有一些改变。

我已将我的Web应用程序从ruby 2.1和Rails 4.0迁移到ruby 2.4.9p362和rails Rails 5.2.4。尝试登录之前,它可以正常工作,但是在迁移之后,我会收到下一条错误消息:Started ...

ruby ruby-on-rails-5
1个回答
0
投票

[render :nothing在5.0中已弃用

© www.soinside.com 2019 - 2024. All rights reserved.