草庐IT

openssl-self-signed-ca

全部标签

ruby - 在哈希参数上迭代调用 self.send 到 initialize()

我正在尝试理解以下Ruby代码。看起来attrs是一个散列,它作为参数传递,默认值为空散列。然后attrs.each迭代散列中的键值对(|k,v|)。在本次迭代中对键值对的元素调用self.send会达到什么效果?definitialize(attrs={},*args)super(*args)attrs.eachdo|k,v|self.send"#{k}=",vendend 最佳答案 send在第一个参数中调用该方法,并将其余参数作为参数传递。在这种情况下,我假设attrs中的内容是一个属性列表。假设它是这样的:{:name=>"

ruby - 在 Ruby 中,在类方法内部,self 是类还是实例?

我知道self是实例方法中的实例。那么,self是类方法内部的类吗?例如,以下内容是否适用于Rails?classPost 最佳答案 没错。类方法中的self是类本身。(也在类定义内部,例如defself.coolpost中的self。)您可以使用irb轻松测试这些花絮:classFoodefself.barputsself.inspectendendFoo.bar#=>Foo 关于ruby-在Ruby中,在类方法内部,self是类还是实例?,我们在StackOverflow上找到一个类

ruby-on-rails - "Certificate verify failed"使用 Ruby 1.9.3 时出现 OpenSSL 错误

我在MacOS10.6.8(使用rvm安装)上使用Ruby1.9.3p0。当我尝试使用applicationtemplatehostedonGitHub创建一个新的Rails应用程序时,用这个(例如):$railsnewmyapp-mhttps://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-devise-template.rb-T-O我收到此错误消息:/Users/me/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:7

ruby-on-rails - rails : Plus sign in GET-Request replaced by space

在Rails3(Ruby1.9.2)中我发送一个请求StartedGET"/controller/action?path=/41_+"但是参数列表是这样的:{"path"=>"/41_","controller"=>"controller","action"=>"action"}这里出了什么问题?-、*或.符号工作正常,只是+将被空格替换。 最佳答案 这是正常的URL编码,theplussignisashorthandforaspace:Withinthequerystring,theplussignisreservedasshor

ruby - OpenSSL、RVM、Brew、冲突错误

当我在终端中运行brewdoctor时:我收到以下错误:Warning:Somekeg-onlyformulaarelinkedintotheCellar.Youmaywishto`brewunlink`thesebrews:openssl如果我取消链接,然后输入rvmrequirements:我将收到以下错误。Checkingrequirementsforosx.dyld:Librarynotloaded:@@HOMEBREW_CELLAR@@/openssl/1.0.1f/lib/libssl.1.0.0.dylibReferencedfrom:/usr/local/opt/ope

ruby - 我如何确保 Ruby 使用不易受到 Heartbleed 攻击的 OpenSSL?

继Heartbleed错误之后,thispostonruby-lang.org描述了如何检查漏洞和升级。它包括这个建议:要验证您链接到Ruby的OpenSSL库版本,请使用以下命令:ruby-v-ropenssl-rfiddle-e'putsFiddle::Function.new(Fiddle.dlopen(nil)["SSLeay_version"],[Fiddle::TYPE_INT],Fiddle::TYPE_VOIDP).call(0)'要验证当前随Ruby安装的OpenSSL版本,请使用以下命令:ruby-ropenssl-e'putsOpenSSL::OPENSSL_VE

ruby - 'yield self' 和 instance_eval 一样吗?

如果用instance_eval:定义Foo有什么不同吗?..classFoodefinitialize(&block)instance_eval(&block)ifblock_given?endend。..或者使用“yieldself”:classFoodefinitializeyieldselfifblock_given?endend无论哪种情况,您都可以这样做:x=Foo.new{deffoo;'foo';end}x.foo所以“yieldself”意味着Foo.new之后的block总是在Foo类的上下文中求值。这是正确的吗? 最佳答案

ruby - 在 Ruby 上获取 OpenSSL::X509::CertificateError 嵌套 asn1 错误

我有来自Apple的.p12文件,并尝试使用以下命令将其转换为.pem文件:opensslpkcs12-incert.p12-outapple_push_notification_development.pem-nodes-clcerts尝试创建新的OpenSSL::X509::Certificate对象时OpenSSL::X509::Certificate.new(File.read('apple_push_notification_development.pem'))我收到以下错误:OpenSSL::X509::CertificateError:nestedasn1errorfro

ruby-on-rails - Ruby on Rails - 设计用户/sign_out 不工作

我正在使用设计sign_in和sign_up网址有效但是,当我尝试url时:http://localhost:3000/users/sign_out它产生路由错误Noroutematches[GET]"/users/sign_out"我该如何解决这个问题?rake路rakeroutesnew_user_sessionGET/users/sign_in(.:format){:action=>"new",:controller=>"devise/sessions"}user_sessionPOST/users/sign_in(.:format){:action=>"create",:con

ruby-on-rails - 如何使用 OpenSSL::Cipher 加密 UTF-8 字符串中的数据?

在Rails3.0(Ruby1.9.2)应用程序中,我正在尝试使用如下方式加密一些数据:cipher=OpenSSL::Cipher.new'aes-256-cbc'cipher.encryptcipher.key=cipher.random_keycipher.iv=cipher.random_ivencrypted=cipher.update'mostsecretdataintheworld'encrypted这将进入UTF-8数据库。我的问题是>encrypted.encoding=>#>encrypted.encode'utf-8'Encoding::UndefinedConv