草庐IT

scoped-lock

全部标签

ruby-on-rails - Rails、已安装的 Gem 版本和 Gemfile.lock 版本

我有一个问题。如果bundle更新,Gemfile.lock总是被提交。今天,当我部署web应用程序时,我看到了这条错误消息,Couldnotfindjwt-1.5.3inanyofthesourcesjwt-1.5.2安装在已部署服务器的共享gem路径中。我认为bundleinstallnewjwt-1.5.3gem因为Gemfile.lock中指定的版本(1.5.3)和安装的版本(1.5.2)不相等。为什么不能bundleinstalljwtgem?如果找不到jwt-1.5.3,是否应该捆绑安装那个gem? 最佳答案 删除Gem

ruby-on-rails - Rails add_index 算法 : :concurrently still causes database lock up during migration

为了防止在迁移到生产站点期间出现数据库事务错误,我们遵循了https://github.com/LendingHome/zero_downtime_migrations中列出的建议。(具体由https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in概述),但在特别大的表上创建索引期间,即使是索引创建的“并发”方法也会锁定表并导致该表上的任何ActiveRecord创建或更新导致各自的事务失败有PG::InFailedSqlTransaction异常。下面是我们运行Rails4.2(使用Acti

ruby - 续集中的 default_scope

在ActiveRecord中有一个default_scope类方法来指定默认范围。例如classUserfalse)endUser.all#=>SELECT*FROMusersWHEREdeleted=0;我如何在Sequel::Model中执行此操作?编辑:经过一番谷歌搜索,我终于找到了一些有用的信息。classUser生成的查询如下所示:User.all#=>SELECT*FROM`users`WHERE(`deleted`ISFALSE)顺便说一下:unscoped等同于unfiltered:User.unfiltered.all#=>SELECT*FROM`users`但是,有

ruby - Cucumber 测试无法启动,错误为 "Display socket is taken but lock file is missing.."

运行cucumber后bundleexeccucumberfeatures/emails.feature:20我遇到了错误Displaysocketistakenbutlockfileismissing-checktheHeadlesstroubleshootingguide(Headless::Exception)/Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/headless-2.2.0/lib/headless.rb:195:inensure_xvfb_is_running'/Users/me/.rbenv/ver

ruby-on-rails - Rails 3.2 ActiveAdmin 'Collection is not a paginated scope.' 错误

我正在使用Rails3.2和ActiveAdmin0.4.4开发应用程序。我有一个名为Teaser的模型(/app/models/teaser.rb):classTeasertruemount_uploader:img,TeaserUploaderend然后我向其中添加了ActiveAdmin(/app/admin/teaser.rb):#encoding:UTF-8ActiveAdmin.registerTeaserdoformdo|f|f.inputs"Teaser"dof.input:name,:label=>'Текст'f.input:url,:label=>'Ссылка'

ruby - 特拉维斯报告损坏的 Gemfile.lock 的奇怪消息

我使用bundler来安装东西,因为我添加了Gemfile.lock,travis开始提示:YourGemfile.lockiscorrupt.ThefollowinggemismissingfromtheDEPENDENCIESsection:'echoe'当然,一切都在本地运行。它也可以使用DeployBot。我什至安装了dockerubuntu并尝试了,仍然可以。我的Gemfile.lock没有损坏。使用相同版本的ruby​​和bundler。这是怎么回事?更新这与bundler版本有关。我使用的是1.11.0,但收到报告说它可以与eg一起使用。1.8.3.??

ruby - RSpec 2之前(:suite) variable scope

基本上我想创建一个数组,然后在我的规范中附加到它,然后再最终处理并将它显示给用户。我可以想出一些解决方法,但理想情况下我想执行以下操作。RSpec.configuredo|config|config.before(:suite){@array_of_stuff||=[]}config.after(:suite){process_and_print(@array_of_stuff)}enddefprocess_and_print(array)#dostuffend不幸但并不令人惊讶的是@array_of_stuff不在范围内并且不能从我的规范中追加,这与在before(:all)bloc

ruby-on-rails - 为什么我得到 "including Capybara::DSL in the global scope is not recommended!"

每次我运行规范,即使规范通过,例如$rspecspec/integration/view_homepage_spec.rbincludingCapybara::DSLintheglobalscopeisnotrecommended!.Finishedin0.6174seconds1example,0failuresRandomizedwithseed14130$我的Gemfile有:group:test,:developmentdogem'rspec-rails'gem'capybara'end我的spec_helper有:ENV["RAILS_ENV"]||='test'requir

Ruby 范围,常量优先级 : lexical scope or inheritance tree

我将向您展示来自rubykoans的代码片段教程。考虑下一个代码:classMyAnimalsLEGS=2classBird实际上问题在评论中(我用星号突出显示了它(尽管它打算以粗体显示))。有人可以解释一下吗?提前致谢! 最佳答案 这里有答案:Ruby:explicitscopingonaclassdefinition.但也许它不是很清楚。如果您阅读链接的文章,它将帮助您找到答案。基本上,Bird是在MyAnimals的范围内声明的,在解析常量时具有更高的优先级。Oyster位于MyAnimals命名空间中,但未在该范围内声明。将

ruby-on-rails - 攻击 ActiveRecord : add global named scope

我正在尝试为像这样的ActiveRecord模型提供一组非常通用的命名范围:moduleScopesdefself.included(base)base.class_evaldonamed_scope:not_older_than,lambda{|interval|{:conditions=>["#{table_name}.created_at>=?",interval.ago]}endendendActiveRecord::Base.send(:include,Scopes)classUser如果命名范围应该是通用的,我们需要指定*table_name*以防止命名问题,如果它们是来自