草庐IT

face_file_name

全部标签

ruby - 加载错误 : cannot load such file -- rspec/core/rake_task

当我rake的时候,我得到了这个错误。AllenLins-MacBook-Pro:geoblacklightallenlin$rake-tResolvingdependencies...Youmust`geminstallbundler`and`bundleinstall`torunraketasksrakeaborted!LoadError:cannotloadsuchfile--rspec/core/rake_task/Users/allenlin/Documents/USpatial/geoblacklight/Rakefile:12:in`require'/Users/alle

ruby-on-rails - 未初始化常量 "Controller Name"

我的路由/资源和Controller有错误。我在routes.rb中有以下内容:#routes.rbresources:usersdoresource:scheduleend我在controllers/users/中设置了一个schedule_controller.rb,我认为它应该是:classUsers::ScheduleController运行rake:routes显示user_schedulePOST/users/:user_id/schedule(.:format)schedules#createnew_user_scheduleGET/users/:user_id/sche

ruby - "file.sync = true"是做什么的?

我查看了文档,但似乎找不到相关部分。谁能告诉我以下代码中调用sync的目的是什么?fh=Tempfile.new('tmp')fh.sync=true 最佳答案 它设置文件的同步模式。这会影响future的操作并导致在没有block缓冲的情况下写入输出。如果f.tty?为真,也就是说,如果文件连接到类似控制台的设备,则输出不是block缓冲的。但是,当输出到管道或文件时,f.tty?将为false,I/O库将切换到block缓冲,也就是说,将输出累积到一个缓冲区并仅在文件关闭、程序退出或缓冲区已满时写入它。这样速度更快,最终结果相同

ruby-on-rails - 未定义的方法 `name' 为 "actionmailer":String

我有一个旧版本的Rails项目,它是使用BrowserCMS构建的在配置/环境文件中RAILS_GEM_VERSION='2.3.4'unlessdefined?RAILS_GEM_VERSION所以我使用rvm安装了这个gems,所以我可以运行它$gemlist***LOCALGEMS***actionmailer(2.3.8,2.3.4)actionpack(2.3.8,2.3.4)activerecord(2.3.8,2.3.4)activeresource(2.3.8,2.3.4)activesupport(2.3.8,2.3.4)bundler(1.1.4)mysql(2.8

ruby - Vagrant File Chef 属性

我正在尝试将我的Vagrant文件配置为具有一些Chef属性,但我一定是做错了什么,因为ChefRecipe使用的是默认值而不是我试图设置的属性。这是我的vagrant文件的配置部分:config.vm.provision:chef_solodo|chef|chef.json={:mysql=>{:server_root_password=>'password'},:nodejs=>{:version=>'0.6.14',:dir=>'/usr/local',:npm=>'1.1.13'}}chef.cookbooks_path="config/env/cookbooks"chef.a

ruby - 获取名称错误 : `format' is not allowed as an instance variable name when testing instance variable with rspec

我有以下测试:let(:client){Descat::Client.new}describe'poblacio'doit'shouldsetformatcorrectly'doclient.poblacio('v1','json','dades')expect(client.instance_variable_get(:format)).toeq('json')endend我有以下正在测试的代码:moduleDescatclassClientBASE_URL='http://api.idescat.cat/'definitialize(attributes={})attributes

ruby-on-rails - 如何让 Rails 中的 named_scope 返回一个值而不是数组?

我想写一个namedscope从它的id中获取记录。例如,我有一个名为Event的模型,我想使用named_scope来模拟Event.find(id)future的灵active。我在我的模型中使用了这段代码:named_scope:from_id,lambda{|id|{:conditions=>['id=?',id]}}我从我的Controller调用它,如Event.from_id(id)。但我的问题是它返回一组Event对象而不是一个对象。因此如果我想获取事件名称,我必须写event=Event.from_id(id)event[0].name而我想要的是event=Even

ruby-on-rails - ruby 错误 : cannot load such file -- rest-client

我正在使用RubyonRails4。我正在努力require'rest-client'在我的Controller中,以便我可以解析从表单中获取的登录信息并将其发送到API。我可以验证gem是否已安装并且也在我的应用程序根目录下的Gemfile中。但是,当我尝试在我的Controller中请求该文件时,它仍然抛出“无法加载此类文件--rest-client”。我用谷歌搜索了这个错误,我看到的大部分答案要么是gem没有安装,要么不在Gemfile中,要么是两者兼而有之。这里的情况也不是。我的Controller是否由于某种原因无法访问rest-clientgem?我必须使用rest-cli

ruby-on-rails - 在 `require' : no such file to load -- iconv (LoadError)

➜expertizagit:(master)✗ruby-vruby1.8.7(2011-06-30patchlevel352)[i686-darwin11.1.0]➜expertizagit:(master)✗rails-vRails2.3.14➜expertizagit:(master)✗script/server/Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3:in`require':nosuchfiletoload--iconv(Load

ruby - 使用 WWW :Mechanize to download a file to disk without loading it all in memory first

我正在使用Mechanize来简化某些文件的下载。目前我的脚本使用以下行来实际下载文件...agent.get('http://example.com/foo').save_as'a_file_name'然而,这会将完整的文件下载到内存中,然后再将其转储到磁盘。你如何绕过这种行为,直接下载到磁盘?如果我需要使用WWW:Mechanize以外的东西,那么我将如何使用WWW:Mechanize的cookies呢? 最佳答案 您真正想要的是Mechanize::Downloadhttp://mechanize.rubyforge.org/