gpt4 book ai didi

ruby-on-rails - 为什么我在Spree::UserSessionsController#new when install spree?中遇到了getSyntaxError

转载 作者:行者123 更新时间:2023-12-03 08:10:24 26 4
gpt4 key购买 nike

我现在有一个旧的Rails应用程序,现在我要重新打开它,以弄清楚为什么我会收到此语法错误。我坚信它与ruby或rails版本有一些联系

gem 'spree', '3.0.0'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: '3-0-stable'

在尝试登录或尝试进入管理面板之前,它一直有效。每次都有相同的错误:

SyntaxError in Spree::UserSessionsController#new

MyProjects/vendor/bundle/gems/devise-3.5.10/app/controllers/devise/sessions_controller.rb:5: syntax error, unexpected '}', expecting keyword_end ..."devise.skip_timeout"] = true } ... ^



sessions_controller.rb
class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, only: [:new, :create]
prepend_before_filter :allow_params_authentication!, only: :create
prepend_before_filter :verify_signed_out_user, only: :destroy
prepend_before_filter only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }

# GET /resource/sign_in
def new
self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
yield resource if block_given?
respond_with(resource, serialize_options(resource))
end

# POST /resource/sign_in
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_flashing_format?
sign_in(resource_name, resource)
yield resource if block_given?
respond_with resource, location: after_sign_in_path_for(resource)
end

# DELETE /resource/sign_out
def destroy
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
yield if block_given?
respond_to_on_destroy
end

protected

def sign_in_params
devise_parameter_sanitizer.sanitize(:sign_in)
end

def serialize_options(resource)
methods = resource_class.authentication_keys.dup
methods = methods.keys if methods.is_a?(Hash)
methods << :password if resource.respond_to?(:password)
{ methods: methods, only: [:password] }
end

def auth_options
{ scope: resource_name, recall: "#{controller_path}#new" }
end

def translation_scope
'devise.sessions'
end

private

# Check if there is no signed in user before doing the sign out.
#
# If there is no signed in user, it will set the flash message and redirect
# to the after_sign_out path.
def verify_signed_out_user
if all_signed_out?
set_flash_message :notice, :already_signed_out if is_flashing_format?

respond_to_on_destroy
end
end

def all_signed_out?
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }

users.all?(&:blank?)
end

def respond_to_on_destroy
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
format.all { head :no_content }
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
end
end
end

最佳答案

问题是第5行使用的是旧语法,而您可能使用的是新版本的ruby。

prepend_before_filter only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }

应该是(请注意 ())
prepend_before_filter(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }

在这里设计更改它:

https://github.com/plataformatec/devise/commit/53957d921b01e993222def6c051901bb4cbe4be9

关于ruby-on-rails - 为什么我在Spree::UserSessionsController#new when install spree?中遇到了getSyntaxError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54183869/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com