草庐IT

cache_method

全部标签

ruby - Heroku,设计 : Getting 'NoMethodError (undefined method ` to_key' for :user:Symbol)'

我不知道它是什么时候发生的,但我收到了这个错误NoMethodError(undefinedmethod'to_key'for:user:Symbol)此行为仅发生在HerokuCedar堆栈上。我使用Devise(1.4.2)通过FacebookonRails3.1.0.rc6和ruby​​1.9.2-p290进行身份验证。它发生在sign_in_and_redirect(:user,authentication.user)行。这是我的方法:defcreateomniauth=request.env['omniauth.auth']authentication=Authenticat

ruby-on-rails - rails 4 : how to use OR between conditions on find methods

我的问题类似于thisone,但那里的答案都没有解决我的具体问题。我想找到类似这样的对象:conditions={first_name:@searchORlast_name:@search}Stuff.where(conditions)显然,这种语法是无效的,但这是我能想到的展示我想做的事情的最简单的方法。我想在复杂/复合条件下使用更简洁的哈希语法。我知道你可以用像这样的“纯字符串条件”手写出来Stuff.where("first_name=#{@search}ORlast_name=#{@search}")...但这不是我想知道的。更新看起来您可以对这样的数组执行OR:Stuff.w

ruby - 停留在 EdgeCase Ruby Koans 上的 about_methods.rb

我正在通过EdgeCaseRubyKoans(www.rubykoans.com)进行黑客攻击,并且卡在about_methods.rbhere中从第35行开始的方法上。.运行rake可预见地失败并告诉我查看第36行。我有理由确定我的assert_match是正确的(“0代表2”),但我不知道是什么失败了。assert_raise(___)行很可能应该在括号之间包含一些内容,但我不知道那应该是什么。任何提示或轻推?非常感谢。编辑:这是有问题的代码的一小段:defmy_global_method(a,b)a+bend-剪辑-deftest_calling_global_methods_w

ruby - 轨道 4 log4r server.rb :78:in `start' : undefined method `formatter'

我已经研究这个话题太久了,所以我必须发布这个。我有几个运行此设置的应用程序,其中一个在rails启动(railss)时完全失败。它们的配置几乎完全相同,但我似乎无法在这里大海捞针。有没有人对如何找到这个问题有任何指示?设置基于:http://blog.mmlac.com/log4r-for-rails/comment-page-1/#comment-1731当我尝试运行railss时:=>BootingWEBrick=>Rails4.0.0applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Run`railsserver-h`f

ruby-on-rails - rails "undefined method for ActiveRecord_Associations_CollectionProxy"

我有这个模型:classStudent如果我在我的movies_controller.rb中写这个:@students=@movie.cinema.companies.students.all我有这个错误:#Company::ActiveRecord_Associations_CollectionProxy:0x00000007f13d88的未定义方法“学生”>如果我这样写:@students=@movie.cinema.companies.find(6).students.all它向我显示了我的select_collection中的正确学生。如何更好地理解这个过程?更新:我需要这部电

ruby-on-rails - 有可能 CanCan can :manage, :all except one or more method?

我在做:can:manage,:allifuser.role=='admin'can:approve,Anunciodo|anuncio|anuncio.try(:aprovado)==falseend我的第二种方法不起作用,因为:manage:all覆盖了它。有一种方法可以声明可以管理除批准之外的所有内容吗?在里面批准我只是做can:approve,Anunciodo|anuncio|user.role=='admin'&&anuncio.try(:aprovado)==falseend什么是更好的解决方案? 最佳答案 尝试换一种

ruby - main :Object (NoMethodError) though method is defined 的未定义方法

我已经使用以下代码片段定义了一个脚本:check_paramsparamdefcheck_params(param)#somecodeend当我运行它时,我得到了undefinedmethod`check_params'formain:Object(NoMethodError) 最佳答案 Ruby期望方法在你调用它之前被声明,尝试在你调用方法之前移动你的方法定义:defcheck_params(param)#somecodeendcheck_paramsparam 关于ruby-main

ruby - Resque worker 发出 "NoMethodError: undefined method ` 执行`"

我不知道我在这里做了什么,但我试图让Rails中的一个Controller将作业排队到Resque,然后工作人员连接到Resque并完成繁重的工作(即比较、数据库条目)。然而,任务甚至没有运行,因为没有关于设置Resque的明确说明。复制粘贴如下:AlsoavailableinGistformat!这是来自Hoptoad的异常行:NoMethodError:undefinedmethod'perform'forViolateq:Module这是“worker”文件的内容:moduleViolateq@queue=:violateqdefperform(nick,rulenumber)#

Ruby 增量 (+=) 引发错误 undefined method '+' for nil :NilClass

以下代码导致了我的问题:classFoodefinitialize(n=0)@n=nendattr_accessor:ndefincn+=1endend调用Foo.new.inc引发NoMethodError:undefinedmethod'+'fornil:NilClass调用Foo.new.n返回0为什么Foo.new.inc会引发错误?我可以毫无问题地执行Foo.new.n+=1。 最佳答案 tldr;某种形式的self.n=x必须始终用于分配给setter。考虑n+=x扩展为n=n+x其中n被绑定(bind)为局部变量因为它

ruby - Aptana 3 ruby​​ 调试器 - DebugThread 循环中的异常 : undefined method `is_binary_data?'

我正在尝试在Aptana3中调试简单的ruby​​文件。classHelloWorlddefinitialize()enddefgreet()puts"helloworld"endendh=HelloWorld.newh.greet断点设置为h.greet在我开始调试后,调试器启动,但是当它尝试初始化ruby​​类时,调试器断开连接并显示消息FastDebugger(ruby-debug-ide0.4.9)listenson:54749ExceptioninDebugThreadloop:undefinedmethod`is_binary_data?'for"#":String当我将断