草庐IT

failed_to_connect_to_backend

全部标签

ruby-on-rails - 带有 redirect_to 的 Flash 通知在 rails 中被破坏

我已更新到Rails2.3.10、Rack1.2.1,现在我的所有即时消息都没有显示。我发现在重定向期间,通知是这样传递的redirect_to(@user,:notice=>"Sorrytherewasanerror")在我看来闪存哈希是空的!map:ActionController::Flash::FlashHash{}但是您可以在Controller中看到该消息。是什么原因?session{:home_zip=>"94108",:session_id=>"xxx",:flash=>{:notice=>"Sorrytherewasanerror"},:user_credential

ruby - 自定义 to_yaml 和 domain_type

我需要定义用于序列化/反序列化对象的自定义方法。我想做类似下面的事情。classPersondefto_yaml_type"!example.com,2010-11-30/Person"enddefto_yaml"stringrepresentingperson"enddeffrom_yaml(yaml)Person.load_from(yaml)endend声明序列化/反序列化的正确方法是什么? 最佳答案 好的,这就是我想出的classPersondefto_yaml_type"!example.com,2010-11-30/pe

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-on-rails - ruby + Mongoid : how to make a required field?

我使用Mongoid的githead版本(因为Rails4),我想制作一个字段必填文档:classMyClassincludeMongoid::Documentfield:name,type:String,required:true我有这个错误:Problem:Invalidoption:requiredprovidedforfield:name.Summary:Mongoidrequiresthatyouonlyprovidevalidoptionsoneachfielddefinitioninordertopreventun...我做错了什么? 最佳答案

ruby-on-rails - ruby rails : Use Variable in link_to helper path

我有一个接收变量bar的HAML部分,我想将该变量注入(inject)到link_to路径中。例如:=link_tonew_foo_path,class:'sourcecard'do.stuff我想用bar替换foo。我试过:=link_tonew_#{bar}_path,class:'sourcecard'do还有许多其他东西,但似乎没有任何效果。想法? 最佳答案 你可以这样试试:link_tosend("new_#{bar}_path"),class:"源卡"do基本上,send使某物成为一种方法或变量,它允许您将该字符串中的所

ruby-on-rails - 动态生成一个 `link_to` 到 Controller Action `edit`

我正在使用RubyonRails3.0.7,我想生成一个link_to到Controller操作edit,动态。我必须在部分模板中使用它,但问题是我正在为不同的模型数据呈现相同的部分模板(也就是说,我在其中传递了不同类实例的局部变量)。所以我不能使用路由“神奇的RoR方式”`edit__path()`.我想做如下的东西:link_to(@resource_class_instance,:action=>'edit')#Thisexampleiswrong,butitsuggeststheidea这可能吗?如果是这样,我该怎么做? 最佳答案

Ruby 要求 'tk' 产生 LoadError : no such file to load -- tk

我无法让ruby​​成功地require'tk'。我正在使用rvm、ruby2.0.0、ActiveTcl-8.6和Ubuntu12.04LTS。我已经运行了随ActiveTcl一起提供的wish,它似乎正在运行。我查看了RVM网站http://rvm.io/integration/tk和几个像这样的StackOverflow问题RVMRubywithTKinstallation(OSX).我在不同版本的ruby​​上多次尝试rvmreinstall2.0.0--enable-shared--enable-pthread--with-tk--with-tcl但没有成功。有什么想法吗?当

ruby-on-rails - `require' : No such file to load -- test_helper (LoadError)

当我在生产模式下运行我的Rails应用程序时出现以下错误,但是当我在开发模式下运行我的应用程序时它工作正常。我可以在生产模式下使用任何Gem吗?`require':Nosuchfiletoload--test_helper(LoadError)以下是完整的代码轨迹:/home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in`require':Nosuchfiletoload--test_helper(LoadError)from/home/

ruby-on-rails - Rake 文档 :app fails after upgrading to Ruby 2. 1.1 和 Rails 4.1

我使用命令rakedoc:app为我的Rails应用程序生成一些基本文档。它在过去一直运行良好。昨天我通过应用程序从Ruby1.9.3升级到2.1.1,从Rails3.2升级到4.1。该应用程序一切正常,所以几周后我第一次重新生成文档,但失败了。我运行上面的命令并收到以下错误消息:rakeaborted!Don'tknowhowtobuildtask'README.rdoc'/home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in`eval'/home/vagrant/.rvm/gems/ruby-2.1.1/