草庐IT

background-saving-is-failing-with

全部标签

ruby-on-rails - postgresql 数据库错误 : Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

当我运行rakedb:migrate或运行railss命令时,我得到同样的错误:Error:couldnotconnecttoserver:NosuchfileordirectoryIstheserverrunninglocallyandacceptingconnectionsonUnixdomainsocket"/var/run/postgresql/.s.PGSQL.5432"?当我尝试railss时,浏览器出现错误。这是我的database.ymldefault:&defaultadapter:postgresqlencoding:unicodepool:5development

ruby-on-rails - 正在尝试安装 libv8, "failed to build gem native extension"

我使用的是W764位。简单地说,当我输入时:C:\Sites>geminstalllibv8我得到这个结果:TemporarilyenhancingPATHtoincludeDevKit...Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallinglibv8:ERROR:Failedtobuildgemnativeextension.C:/RailsInstaller/Ruby1.9.3/bin/ruby.exeextconf.rbcreatingMakefilewhich:nogmakein("myPAT

ruby-on-rails - 在 rails3 的 Controller 上使用 number_with_precision

我想在Controller上使用这个辅助方法。有什么办法可以实现吗? 最佳答案 可能不是一个好主意,但如果必须,请像这样包含帮助程序:classWhateverControllerincludeActionView::Helpers::NumberHelperdefshowrender:text=>number_with_precision(2342.234,:precision=>2)endend 关于ruby-on-rails-在rails3的Controller上使用number_

ruby-on-rails - 为什么使用触摸时after_save不触发?

最近几天,我尝试使用Redis存储来缓存Rails应用程序。我有两个模型:classCategory和classProduct在Controller中defindex@products=$redis.get('products')if@products.nil?@products=Product.joins(:category).pluck("products.id","products.name","categories.name")$redis.set('products',@products)$redis.expire('products',3.hour.to_i)end@pro

ruby-on-rails - Heroku 和 Rails : Gem Load Error with Postgres, 但它在 GEMFILE 中指定

所以我正在尝试将一个小项目部署到Heroku,但是当我部署它并尝试运行herokurunrakedb:migrate时,它返回了以下错误:rakeaborted!Gem::LoadError:Specified'postgresql'fordatabaseadapter,butthegemisnotloaded.Add`gem'pg'`toyourGemfile(andensureitsversionisattheminimumrequiredbyActiveRecord)./app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/li

ruby - Rubocop 错误 'Class definition is too long ruby'

我收到rubocop错误“类定义太长。[236/100]'。我的类(class)如下所示:classSomeClassNameincludeHelperModuleattr_accessor:aaa,:bbb,:ccc....methods.....end可能会出现什么问题?rubocop文档ClassLength说“一个类(class)的长度超过了某个最大值”。什么意思? 最佳答案 是的,这是因为rubucop认为整体线路太多。我同意类(class)不应该太长,但认为最终应该由以下因素决定:类(class)是否有单一职责,方法是否

ruby-on-rails - 有办法处理 `after_save` 和 `after_destroy` "equally"吗?

我正在使用Rails3.1.0,我想知道是否可以“平等地”处理after_save和after_destroy回调。也就是说,我需要为after_save和after_destroy回调运行相同的方法。此时我必须分别处理这些回调,即使它们完成的是同一件事:after_savedo|record|#Makeathingendafter_destroydo|record|#Makethesamethingasinthe'after_save'callbackend那么,有一种方法可以“平等地”处理after_save和after_destroy吗? 最佳答案

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 - nokogiri 不会安装 - 错误 : Failed to build gem native extension

这个问题在这里已经有了答案:`require':nosuchfiletoload--mkmf(LoadError)(10个答案)关闭9年前。在ubuntu12.04上,我得到以下信息。sudoapt-getinstalllibxml2libxml2-devlibxsltlibxslt-devsudogeminstallnokogiriBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingnokogiri:ERROR:Failedtobuildgemnativeextension./usr/bin/ruby

ruby - 为什么不推荐使用 Enumerable#each_with_object?

根据APIdock,Ruby方法Enumerable#each_with_object已弃用。除非它是错误的(说“在最新稳定版本的Rails上弃用”让我怀疑可能是Rails的猴子补丁被弃用了),为什么它被弃用了? 最佳答案 这更像是对否定你问题的预设的回答,也是为了确定它是什么。each_with_object方法可以节省您额外的击键次数。假设您要从数组中创建散列。使用inject,你需要一个额外的hin:array.inject({}){|h,a|do_something_to_h_using_a;h}#但使用each_with_