草庐IT

not-when-fast-scrolling

全部标签

ruby-on-rails - 安装 ruby​​ gems 后,运行新的 gem 返回 "Could not find"错误

全新的Ubuntu10.04安装:我在让我的gem安装过程正常运行时遇到了一些问题。每当我安装gem时,它都会通过一个漂亮、直接的过程,没有任何问题:$geminstallrailsSuccessfullyinstalledrails-3.2.21geminstalled然后验证版本,也许是一个简单的“rails-v”?不:$rails-v/home/pragone/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in`to_specs':Couldnotfindrailti

ruby "instance variable not initialized"警告

在用ruby​​编写一些“学习语言”代码时,作为linkedList实现的一部分,我遇到了这个警告:在“添加”方法中,如果头部不存在则创建它,即defadd(value)new_node=LinkedListNode.new(value)if!@head@head=new_nodeelseself.find{|node|node.next==nil}.next=new_nodeendend然后我收到警告.../linked_list.rb:13:warning:instancevariable@headnotinitialized如何摆脱这个警告?这样做的惯用方法是什么?

ruby-on-rails - 自定义验证 :on => :create not working

我有一个自定义验证方法,我只想在创建时执行:validate:post_count,:on=>:createdefpost_count#validatestuffend但是,它会在更新时被触发(除了在创建时)。:on=>:create选项是否不适用于自定义验证方法? 最佳答案 据我所知,没有:on选项。使用validate_on_create:post_count相反。还有validate_on_update。您可以阅读有关此方法的信息here. 关于ruby-on-rails-自定义验

ruby-on-rails - 验证失败 : Upload file has an extension that does not match its contents

我正在使用回形针gem上传文件。我的回形针gem版本是paperclip-4.1.1。上传文件时抛出Validationfailed:Uploadfilehasanextensionthatdoesnotmatchitscontents.我正在尝试上传xlsx文件。而且我已经在模型content_type中提到了这一点。validates_attachment_content_type:upload_file,:content_type=>%w(application/mswordapplication/vnd.ms-officeapplication/vnd.ms-excelappl

ruby - 无法运行 Jenkins Build - bundle : "command not found"

我目前正在尝试为我的一些cucumber任务运行jenkins构建。我所有的gem都是使用Bundler安装的。Gem存储在vendor文件夹中。但是,当我尝试在执行shell构建步骤中运行bundleinstall--deployment时,出现以下错误:StartedbyuseranonymousBuildinginworkspace/Users/Shared/Jenkins/Home/jobs/cukes/workspace[workspace]$/bin/sh-xe/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson44

ruby-on-rails - rails : rbenv rehash not working (rbenv-shim exists)

我正在尝试在安装新gem后重新哈希rbenv它在我的ubuntu服务器上给了我这些错误rbenv:cannotrehash:/home/deployer/.rbenv/shims/.rbenv-shimexists但是.rbenv-shims不存在 最佳答案 可能是issuewithdirectorypermissions@sstephenson/rbenv:FWIW-Ialsohadthisproblem,andhadtochangepermissionsonthedirwhereitwascheckingforthe.rbenv

ruby-on-rails - rails 4 : Error when installing tiny_tds gem?

我使用Rubyv2和Railsv4开发了一个RailsWeb项目。它在我当前的系统中运行良好,当我尝试在另一台Linux机器(Ubuntu12.4)中运行该项目时,出现Tidy_tds错误。此错误在bundleinstall时显示,错误详情如下Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./home/action/.rvm/rubies/ruby-2.1.1/bin/rubyextconf.rbcheckingforiconv_open()iniconv.h...yescheckingforsybfront.h..

ruby-on-rails - Mac OS X 山狮 "Rails is not currently installed on this system."

我正在全新安装OSXMountainLion。我通过以下方式安装了Rails:sudogeminstallrails一切似乎都安装正确,但是当我键入rails命令(railss、rails-v等)时,我收到此错误:Railsisnotcurrentlyinstalledonthissystem.Togetthelatestversion,simplytype:$sudogeminstallrailsYoucanthenrerunyour"rails"command.'whichrails'的结果是/usr/bin/rails我认为这是一个路径问题,也许是,但我可以看到/usr/bin是

ruby - RVM + Zsh "RVM is not a function, selecting rubies with ' rvm 使用.. .' will not work"

首先我要说我不是命令行专家,所以我真的几乎不知道自己在做什么。我无法让RVM和oh-my-zsh一起玩得很好。我尝试了几种不同的解决方案,其中一些是在SO上发布的,但我发现似乎没有任何解决方案可以解决问题。最初,其他人在我的机器上安装了RVM。后来我自己设置了oh-my-zsh,记得当时遇到了很多麻烦。除了这两行,我的.zhsrc文件是完全默认的exportPATH=$HOME/bin:/usr/local/bin:/usr/local/rvm/bin:$PATH#prettysurethislinedoesnothing,althoughI'veseenthisfixaround#s

ruby-on-rails - RSpec 故事和规范 : When to use what?

所以我想开始使用RSpec故事,但我不确定编写Controller、模型和View规范的位置。例如,您有“登录”故事和“用户提供错误的密码”场景,难道您最终测试的不是与Controller/模型规范相同的东西(response.shouldrender...,user.shouldbe_nil等)所以我的问题是:对于那些习惯于使用RoR进行bdd(或故事dd)的人,您是否仍然编写模型/Controller规范?如果是这样,您遵循的工作流程如何(“第一个故事,然后缩小到特定规范”)? 最佳答案 如果您现在开始使用故事(而不是拥有大量遗