草庐IT

get_loaded_extensions

全部标签

ruby LoadError : cannot load such file

例如,当我需要一个文件(称为st.rb)时:require'rubygems'require'mongrel'classTestHandler在irb中我得到:>>require'st.rb'LoadError:cannotloadsuchfile--st.rbfrom/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from(irb):3from/usr/loc

ruby - load 在本地路径上工作,require 不

加载器.rbputs'>Thisisthesecondfile.'加载演示.rbputs'Thisisthefirst(master)programfile.'load'loadee.rb'puts'Andbackagaintothefirstfile.'当我运行"rubyloaddemo.rb"时,效果很好。这两个文件都在同一个目录中,这就是我运行的目录。但是,如果我将负载更改为要求,无论有无扩展名,我都会得到::29:in`require':nosuchfiletoload--loadee.rb(LoadError)from:29:in`require'fromloaddemo.r

ruby-on-rails - Rails : how to get the current host, 或用它构建 URL?

这个问题在这里已经有了答案:GettingtheHostnameorIPinRubyonRails(12个答案)关闭8年前。我需要使用主机构建具有不同端口的URL。例如,如果主机是example.com,我需要生成类似http://example.com:8080/的URL我需要它是便携的,所以当我在本地环境中时,它会显示http://localhost:8080/相反。有什么想法吗?

ruby -v dyld : Library not loaded:/usr/local/lib/libgmp. 10.dylib

我一直在尝试在终端中运行脚本,每次我都会得到:$rubydirectory.rbdyld:Librarynotloaded:/usr/local/lib/libgmp.10.dylibReferencedfrom:/Users/claretrembath/.rvm/rubies/ruby-2.1.3/bin/rubyReason:imagenotfoundTrace/BPTtrap:5我意识到在检查ruby-v时我得到了相同的输出:$ruby-vdyld:Librarynotloaded:/usr/local/lib/libgmp.10.dylibReferencedfrom:/Use

ruby-on-rails - 尝试在测试中运行 rails c 时获取 config.eager_load 设置为 nil

我正在尝试运行Rails(4.1.2)控制台railscRAILS_ENV=test我得到这个:>config.eager_loadissettonil.Pleaseupdateyour>config/environments/*.rbfilesaccordingly:>>*development-setittofalse*test-setittofalse(unless>youuseatoolthatpreloadsyourtestenvironment)*production->setittotrue>>/Users/xxxxxx/.rvm/gems/ruby-2.2.2/gems

ruby-on-rails - RSpec 测试使用 GET 参数重定向到 URL

假设我有一个带有redirect_to_baz方法的FoosController。classFoosController我正在使用spec/controllers/foos_controller_spec.rb对此进行测试:require'spec_helper'describeFoosController,:type=>:controllerdodescribe"GETredirect_to_baz"doit"redirectstoexample.comwithparams"doget:redirect_to_bazexpect(response).toredirect_to"htt

ruby-on-rails - Ruby Net::HTTP::Get 和 JSON 响应

我正在尝试连接到API并使用我的Rails应用检索json结果,但它似乎不起作用。举个例子:@request=Net::HTTP::Get.new"http://example.com/?search=thing&format=json"当我在浏览器中尝试url时,它有效!我得到JSON数据,但是当我在Ruby中尝试时,正文为零。>>y@request---!ruby/object:Net::HTTP::Getbody:body_stream:header:accept:-"*/*"user-agent:-Rubymethod:GETpath:http://example.com/?s

ruby-on-rails - rails 3.1 ActionController::RoutingError(没有路由匹配 [GET] "/assets/rails.png"):

标准的新Rails应用程序在显示rails.png时出现问题ActionController::RoutingError(Noroutematches[GET]"/assets/rails.png"):我曾尝试将.png文件移动到Assets和Assets/图像中的各个位置以及旧位置“公共(public)”或“公共(public)/图像”并更改页面,但没有任何帮助。如果您已经看到并解决了这个问题,请回答。我自己尝试了大约20种不同的组合。版本:'rails','3.1.0.rc4' 最佳答案 我刚刚遇到了类似的错误。在我的例子中,我

ruby-on-rails - 安装调试器时出错 : Failed to build gem native extension with ruby-1. 9.3-p362

尝试为新项目运行bundle时,遇到以下错误:Installingdebugger(1.2.2)withnativeextensionsGem::Installer::ExtensionBuildError:ERROR:Failedtobuildgemnativeextension.C:/Ruby193/bin/ruby.exeextconf.rbcheckingforrb_method_entry_t.called_idinmethod.h...nocheckingforrb_control_frame_t.method_idinmethod.h...nocheckingforrb_

ruby - 如何使用 Sinatra 进行 Post/Redirect/Get?

Sinatra中Rails的redirect_to方法有什么等价物?我需要遵循表单提交的Post/Redirect/Get流程,同时保留传递到我的View的实例变量。使用redirect方法时实例变量丢失。 最佳答案 Sinatra中的重定向是最简单易用的。所以下面的代码可以解释:require'rubygems'require'sinatra'get'/'doredirect"http://example.com"end您也可以像这样重定向到当前应用程序中的另一个路径,尽管此示例将删除一个方法。delete'/delete_pos