草庐IT

state-pattern

全部标签

ruby-on-rails - Puma .state 文件

我正在尝试使用Capistrano部署带有puma的Rails应用程序。在部署结束时它尝试运行bundleexecpumactl-S/home/deployer/production/shared/sockets/puma.state重启失败了/undefinedmethod`has_key?'forfalse:FalseClass.我只是为puma.state创建了一个空文件。我的问题是这个文件到底是什么,里面应该有什么? 最佳答案 Puma有一个状态文件,记录了进程的PID。如果你是第一次部署,你应该删除.state文件,然后做

ruby-on-rails - 使用 state_machine 进行条件验证

我正在使用state_machine构建一个多步骤表单,在过渡到下一步之前验证每个步骤的字段。这是我的模型:classFoo:step1doevent:nextdotransition:step1=>:step2transition:step2=>:step3endevent:previousdotransition:step3=>:step2transition:step2=>:step1endstate:step1dovalidates_presence_of:field1endstate:step2dovalidates_presence_of:field2endstate:st

ruby-on-rails - rails : replacing try with the Null Object Pattern

在我的大多数应用程序中,我都有一个current_user方法。为了避免像current_user.name这样的情况出现异常,其中current_user是nil,rails提供了try方法。这个问题是我需要记住在current_user可能是nil的地方使用try。我想使用NullObject模式来消除这种额外的开销。classNullUserdefmethod_missing(method_name,*args)nilendenddefcurrent_userreturnNullUser.newunlessUserSession.find@current_user||=UserS

ruby-on-rails - state_machine 仅适用于新记录

我似乎无法获得state_machinegem(http://github.com/pluginaweek/state_machine/)来处理现有记录(它可以在新记录上正常工作)。这是我的模型:classComment:pendingdoevent:publishdotransitionall=>:publishedendendend这是一个演示该问题的IRBsession(我做了ActiveRecord::Base.logger=Logger.new(STDOUT)以使其更易于阅读):>>c=Comment.new=>#>>c.state=>"pending">>c.publish

org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not

文章目录一.搭建集群时出现错误错误日志elasticsearch.logorg.elasticsearch.cluster.block.clusterblockexception:blockedby:[service_unavailable/1/statenotrecovered/initialized];原因:解决方案:一.搭建集群时出现错误错误日志elasticsearch.logorg.elasticsearch.cluster.block.clusterblockexception:blockedby:[service_unavailable/1/statenotrecovered/i

ruby - SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: 版本号错误 (OpenSSL::SSL::SSLError)

当我运行https.ssl_version=:TLSv1_2我得到了错误ruby/2.1.0/net/http.rb:920:in`connect':SSL_connectreturned=1errno=0state=SSLv3readserverhelloA:wrongversionnumber(OpenSSL::SSL::SSLError)当我更改为https.ssl_version=:SSLv3ruby/2.1.0/net/http.rb:920:in`connect':SSL_connectSYSCALLreturned=5errno=0state=SSLv3readserve

ruby-on-rails - SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 读取服务器 hello A - Faraday::Error::ConnectionFailed

我在这里看到了很多答案,但没有一个有效。我正在使用omniauth-oauth2gem与第三方客户集成。我正在使用描述的设置阶段here但我总是收到这个错误:Authenticationfailure!failed_to_connect:Faraday::Error::ConnectionFailed,SSL_connectSYSCALLreturned=5errno=0state=SSLv2/v3readserverhelloAFaraday::Error::ConnectionFailed(SSL_connectSYSCALLreturned=5errno=0state=SSLv2

ruby-on-rails - state_machine 中状态的命名范围

我使用state_machine在我的Rails3.1应用程序之一上使用ActiveRecord。我发现访问具有不同状态的记录的语法很麻烦。是否可以将每个状态同时定义为作用域而不用手写作用域定义?考虑以下示例:classUser:foodostate:foostate:bar#...endend#state_machinesyntax:User.with_status:fooUser.with_status:bar#desiredsyntax:User.fooUser.bar 最佳答案 我正在将以下内容添加到我的模型中:state_

ruby - SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 读取服务器 hello A

我有一个使用IMAP和SSL连接到交换服务器的ruby​​客户端。我使用RubyNet::IMAP库(在幕后使用openssl)进行连接。它已经工作了几个月。交换服务器管理员从godaddy安装了新证书,现在我收到此错误:SSL_connectSYSCALLreturned=5errno=0state=SSLv2/v3readserverhelloA有谁知道这个错误是什么意思?(我试过谷歌搜索)我怀疑新证书有问题导致了这个问题,但我不知道如何解决它。另外我知道您可以在使用NET:HTTP时禁用证书验证:http.verify_mode=OpenSSL::SSL::VERIFY_NONE

ruby-on-rails - OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=unknown 状态:未知协议(protocol)

我关注了很多关于这个问题的帖子,但没有一个对我有帮助。我正在尝试使用最简单的irb命令进行连接:require'open-uri'open('https://aristo4stu3.bgu.ac.il')奇怪的是,对于我尝试过的任何其他httpsuri,它都工作正常(即https://google.com)。出于调试目的,我什至尝试使用以下方法禁用SSL验证:OpenSSL::SSL::VERIFY_PEER=OpenSSL::SSL::VERIFY_NONE这似乎也没有帮助。我的设置是(在AWS上):$rvm-vrvm1.21.3(stable)byWayneE.Seguin,Mic