草庐IT

could_not_write_file

全部标签

ruby-on-rails - 脚本/服务器 custom_require.rb :36:in `require' : cannot load such file -- test/unit/error (LoadError)

我有一个基于1.8.7构建的应用程序,我正尝试在1.9.3的系统上启动它当我运行脚本/服务器时,我得到:/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require':cannotloadsuchfile--test/unit/error(LoadError)from/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'我的服务器脚本如下所示:#!/usr/bin/envrubyrequireFile.expand_path('../.

ruby - 获取错误 : dyld: Symbol not found: _clock_gettime

我想用middlemanserver命令启动一个中间人,当我这样做时我得到一个错误:dyld:lazysymbolbindingfailed:Symbolnotfound:_clock_gettimeReferencedfrom:/usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/rubyeventmachine.bundle(whichwasbuiltforMacOSX10.12)Expectedin:/usr/lib/libSystem.B.dylibdyld:Symbolnotfound:_clock_gett

ruby - 为 IO::popen 拯救 "command not found"

当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby​​1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#

ruby-on-rails - 如何防止错误 "code converter not found (UTF-8)"?

我在生产环境(CentOS5.6)中遇到此错误,但在开发环境(Ubuntu11.04)中运行良好。在这两种环境中,该应用程序都使用Ruby1.9.3和Rails3.0.9,并由passenger和nginx提供服务。我的Mechanizegem版本是2.3。未找到代码转换器(UTF-8)此代码的最后一行触发它:mech=Mechanize.newpage=mech.get("http://myurl.com/login.php?login_name=a&password=b")form=page.form_with(:name=>"loginForm")form.field_with(

ruby-on-rails - rails 5 : Autoloading with custom folders not working

我有这门课:#app/events/new_request.rbclassEvents::NewRequestend然后我将该文件夹添加到自动加载:#config/application.rbconfig.autoload_paths+=%W(events/)当运行railsc时:>Events::NewRequestNameError:uninitializedconstantEvents问题是,如果我在定义类时不使用命名空间“Events”,它会成功自动加载类。 最佳答案 moduleSandboxclassApplicatio

ruby-on-rails - 如何从 ruby​​ 父类(super class)中的方法访问子类中的当前 __FILE__

我希望为日志设置一个默认路径,相对于使用日志的文件路径,像这样:#/path/to/lib/bar.rbclassBardefsettings_file_pathFile.dirname(File.expand_path(__FILE__))endend#/path/to/app/models/foo.rbclassFoo理想输出:#=>/path/to/app/models实际输出:#=>/path/to/lib因为FILE引用了它写入的文件,而不是它被调用的地方,它返回bar.rb文件,但我想要这样的东西返回foo.rb文件的路径,即使该方法是在Bar中定义的。有人有什么建议吗?

Ruby/Sinatra send_file 不工作

我在Sinatra应用程序上使用send_file:get'/update/dl/:upd'dofilename="/uploads/#{params[:upd]}"send_file(filename,:filename=>"t.cer",:type=>"application/octet-stream")end/uploads/文件夹不是公开的,它在应用程序目录中。当我尝试在Chrome中访问localhost:4567/update/dl/some_file时,它会返回404,就像在Firefox中一样,当看到标题时,它是404。但是如果我尝试使用Safari,它下载文件。所以我

ruby-on-rails - 为什么在编写 Rails 测试时是 'assert_not' 而不是 '!'?

考虑这个例子,我们想检查是否允许用户使用空白名称(不应该):test"nameshouldbepresent"do@user.name=""assert_not@user.valid?end问题是为什么assert_not存在?如果我们像这样使用assert会不会更好:test"nameshouldbepresent"do@user.name=""assert!@user.valid?end 最佳答案 它可能存在用于从您的断言中删除修饰符,这可能会改变它们的结果或模糊您实际询问的内容。实际上,这主要是一种风格选择。在语言中使用unl

ruby-on-rails - Rails 使用 send_data 或 send_file 将多个文件发送到浏览器

我正在尝试向浏览器发送多个文件。我不能像下面的代码一样为每条记录调用send_data,因为我收到双重渲染错误。根据thispost我需要创建文件并压缩它们,以便我可以在一个请求中发送它们。@records.eachdo|r|ActiveRecord::Base.include_root_in_json=true@json=r.to_jsona=ActiveSupport::MessageEncryptor.new(Rails.application.config.secret_token)@json_encrypted=a.encrypt_and_sign(@json)send_da

ruby-on-rails - 活跃商家 : How to authorise cards when using gateways that do not support the void operation?

我正在使用ActiveMerchant开发RubyonRails应用程序的计费组件。我们选择的支付网关是PaymentExpress.我看到的代码示例如下所示,使用authorize()和void()来测试卡的有效性:deftest_card!auth_response=gateway.authorize(100,card)gateway.void(auth_response.authorization)ifauth_response.success?raiseAuthorizationFailed.new(auth_response)unlessauth_response.succe