草庐IT

symbol_get

全部标签

ruby-on-rails - Rails 3.1 和 Ruby 1.9.3p125 : ruby-debug19 still crashes with "Symbol not found: _ruby_threadptr_data_type"

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:ruby-debugwithRuby1.9.3?我听说ruby​​1.9.3p125有解决ruby​​-debug19问题的传言,所以根据RVM站点上的说明,我重新安装了1.9.3:$rvmreinstall1.9.3--patchdebug--force-autoconf$ruby-vruby1.9.3p125(2012-02-16revision34643)[x86_64-darwin11.2.0]然后:geminstallruby-debug19将此条目添加到我的Gemfile中:gem'ruby-de

ruby - 如何使 Ruby 的 Find.find 遵循符号链接(symbolic link)?

我有一个文件层次结构,一些子目录是相对符号链接(symboliclink)。我正在使用Ruby'sFind.find爬取这些目录并找到一些特定文件。但是,它不会查看任何作为符号链接(symboliclink)的目录(它跟随作为符号链接(symboliclink)的文件)。查看sourcecode看来问题是因为它正在使用File.lstat(file).directory?来测试某物是否是目录。这对符号链接(symboliclink)返回false但File.stat.directory?返回true。如何让Find.find跟随符号链接(symboliclink),而不是猴子修补它以使

ruby - 如何在具有通配符的 RSpec 中请求(GET/POST)路由

我在Rails中有这条(公认的丑陋的)路线:scope'/software'dopost'/:software_id/:attachment_id/event/*event'=>'software#post_event',as:'post_event'end(如果不是遗留API,我会更改它)我正在为它编写一个RSpec测试。rakeroutes给我:post_eventPOST/software/:software_id/:attachment_id/event/*event(.:format)api/version1301/software#post_event我的测试是这样的:de

Ruby Koans #75 test_constants_become_symbols,正确答案?

我的问题基于这个问题:RubyKoan:Constantsbecomesymbols.我有以下代码:in_ruby_version("mri")doRubyConstant="Whatisthesoundofonehandclapping?"deftest_constants_become_symbolsall_symbols=Symbol.all_symbolsassert_equal__,all_symbols.include?(__)endend正确答案应该是下面的吗?assert_equaltrue,all_symbols.include?("RubyConstant".to_

ruby-on-rails - minitest_plugin.rb :9 getting wrong number of arguments

~/Sites/sample_app$railstestRunningviaSpringpreloaderinprocess24338Runoptions:--seed58780Running:..Finishedin0.292172s,6.8453runs/s,6.8453assertions/s./var/lib/gems/2.3.0/gems/railties-5.1.0/lib/rails/test_unit/minitest_plugin.rb:9:in`aggregated_results':wrongnumberofarguments(given1,expected0)(

ruby - 为什么没有更多的项目使用 Ruby Symbols 而不是 Strings?

当我第一次开始阅读和学习ruby​​时,我读到了一些关于ruby​​符号相对于字符串的强大功能:符号只在内存中存储一​​次,而字符串每个字符串在内存中存储一​​次,即使它们是相同的。比如:Rails的paramsHash在Controller中有一堆key作为符号:params[:id]orparams[:title]...但是Sinatra和Jekyll等其他规模适中的项目不会这样做:杰基尔:post.data["title"]orpost.data["tags"]...西纳特拉:params["id"]orparams["title"]...这使得阅读新代码变得有些棘手,并且难以转

ruby 公案 : Constants become symbols

在about_symbols.rbRubyKoan(https://github.com/edgecase/ruby_koans)中,我有以下代码:RubyConstant="Whatisthesoundofonehandclapping?"deftest_constants_become_symbolsall_symbols=Symbol.all_symbolsassert_equaltrue,all_symbols.include?(:"nonexistent")assert_equaltrue,all_symbols.include?(:"Whatisthesoundofoneh

ruby-on-rails - rails : Where does new_*something*_path variable get set up?

我为“消息”创建了一个脚手架,并且new_message_path和edit_message_path(用于link_to's)都已设置,但现在我已经创建了app/views/messages/sent.html.erb,我想做类似的内容,但我不知道该怎么做。我明白了undefinedlocalvariableormethod`sent_message_path'for# 最佳答案 这些方法是在定义路由时自动创建的,对于RESTful路由,它们遵循可预测的约定。运行“rakeroutes”是查看生成的所有路由的有用方法。我建议您阅读

ruby - 使用参数重定向 POST/GET 请求的 Sinatra 应用程序

我正在迁移服务器,但不幸的是,旧服务器IP已硬编码在我的iPhone应用程序中。显然,我将提交一个更新,将API端点设置到我的新服务器,但与此同时,我需要在旧服务器上设置一个应用程序,将所有请求重定向到新服务器。我听说Sinatra非常适合这个。require'sinatra'get"/foo/bar"doredirect"http://new-server.com/foo/bar",303endpost"/foo/bar"doredirect"http://new-server.com/foo/bar",303end问题是它们不会随请求一起转发GET或POST参数。我在Sinatra

ruby - Ruby 的 Object#const_get 是如何工作的?

我最近发现Ruby(2.2.1)有一些“有趣”的行为。moduleFooclassFooendclassBarendendFoo.const_get('Foo')#=>Foo::FooFoo.const_get('Bar')#=>Foo::BarFoo.const_get('Foo::Foo')#=>FooFoo.const_get('Foo::Bar')#=>NameError:uninitializedconstantFoo::Foo::BarFoo.const_get('Foo::Foo::Bar')#=>Foo::BarFoo.const_get('Foo::Foo::Foo: