草庐IT

operation_requiring_synchronizati

全部标签

ruby-on-rails - 创建新的 Rails 3 项目时出错 : `require' : cannot load such file -- openssl (LoadError)

当我尝试创建一个新项目($railsnewfirst_app)时,它在创建目录结构后出现以下错误。......createvendor/plugins/.gitkeeprunbundleinstall/home/amit/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in`require':cannotloadsuchfile--openssl(LoadError)from/home/amit/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site

ruby - Heroku 应用程序无法启动 - `require' : no such file to load -- sinatratestapp (LoadError)

我正在尝试使用bamboo-mri-1.9.2堆栈运行我的Heroku应用程序。当然,它在Ruby1.9.2上本地运行良好。但是在生产环境中,它在执行config.ru的启动过程中崩溃,如下所示:require'sinatratestapp'runSinatra::Application我的.gems文件:sinatra--version'>=1.0'应用程序本身为sinatratestapp.rb:require'rubygems'require'sinatra'get'/'do"HellofromSinatraonHeroku!"end这就是我在项目中得到的所有内容,并尝试在Her

ruby - 是否有可能 'unload' ('un-require' ) 一个 Ruby 库?

我希望加载一些库,让它们做一些工作,然后执行与require相反的操作,以避免以后出现兼容性错误。我不想转储到文件并重新启动shell,因为创建的对象(例如data)可以由我的其他库很好地处理,只是不存在早期我要卸载的那些。有人有任何建议或知道这是否可行吗?Aconversationfrom2006除了“看起来Webrick设法以某种方式做到这一点”之外,没有得出太多结论。有问题的库是Google_driveandNokogiri(电子表格处理库Roo依赖Google_drive进行在线电子表格读/写,如该链接所述)。 最佳答案 正

ruby-on-rails - 停用 Gem - "you have already activated rake 0.9.3.beta.1, but my Gemfile requires rake 0.9.2"

我正在尝试运行迁移,但我不断收到错误消息:rakeaborted!Undefinedmethodprerequisitefornil:NilClass.似乎我以某种方式激活了一个名为rake0.9.3.beta.1的gem-但是我已经更改了gembundleinstall并运行bundleshowrake并且它显示安装了rake0.9.2。我是第一次使用Git,所以我认为这可能与仍在使用测试版rake的应用程序有关-但我已经完成了推送,它显示gemfile已更新。当我向下查看gem库时,我只能看到rake0.9.2版本。我应该看哪里?我还有一条Rails:Railtie弃用警告-但我认

ruby - rspec expect语法不支持operator matchers,所以必须传一个matcher给 `#to`

使用新的expect语法:expect(@line.filter_results_and_display_them).to==@processed出现此错误:ArgumentError:Theexpectsyntaxdoesnotsupportoperatormatchers,soyoumustpassamatcherto'#to' 最佳答案 此语法有效:expect(@line.filter_results_and_display_them).toeq@processed 关于ruby

ruby-on-rails - 回形针错误 : model missing required attr_accessor for 'avatar_file_name'

然后我想使用Paperclip为每个列表拍摄照片。我向listshow.html.erb、listing.rb模型、listings_controller.rb和_form.html.erb部分添加了适当的代码。当我尝试为list上传图片时出现此错误:Paperclip::ErrorinListingsController#updateListingmodelmissingrequiredattr_accessorfor'avatar_file_name'listings_controller的第44行:defupdaterespond_todo|format|if@listing.u

css - Rails - @import 和 *= require 之间的区别?

所以我有一个相对简单的Rails应用程序,我想通过Bootstrap向它添加一些Material设计样式。我已将以下gem添加到我的Gemfile中:gem'bootstrap-sass'gem'bootstrap-material-design'现在它们都可以工作了,我的问题是为什么我似乎必须以不同的方式将它们添加到我的应用程序中。对于vanillaBoostrap,我只是像正常一样将它导入特定View(我认为这是正确的术语)scss文件。@import"bootstrap-sprockets";@import"bootstrap";但是对于MaterialDesigngem,我必须

ruby - bundle exec 和 require 'bundler/setup' 是否等效?

这些事情完成的是否完全相同?使用bundleexecruby​​foo.rb启动ruby​​进程将require"bundler/setup"作为foo.rb的第一行 最佳答案 在您的特定示例中,它们可以被认为是相同的,但实际上它们并不相同。bundleexec对bundler/setup没有进行的环境进行了一些更改。如果您的foo.rb从不运行子shell,或者从不尝试在子shell中运行其他ruby​​可执行文件,那么这两个版本是等效的(它们都将正确加载bundle的gem并且工作完全相同)。bundleexec的整个想法是让您

Ruby 最佳实践 : if not empty each do else in one operator

1.我找不到一种优雅的方式来编写这段代码:ifarray.empty?#processemptyarrayelsearray.eachdo|el|#processelendend我想要一个循环,而不用写两次array。我读了this,但没有足够好的解决方案。2。我实际上在HAML模板中。同样的问题。-ifarray.empty?%pNoresult-else%ul-array.eachdo|el|%liel 最佳答案 怎么样?array.eachdo|x|#...puts"x",xend.empty?andbeginputs"emp

ruby - 使用 Hash#dig 或 Lonely operator(&.) 安全地为嵌套哈希赋值

h={data:{user:{value:"JohnDoe"}}}要为嵌套哈希赋值,我们可以使用h[:data][:user][:value]="Bob"但是如果中间的任何部分缺失,就会导致错误。有点像h.dig(:data,:user,:value)="Bob"不会工作,因为还没有可用的Hash#dig=。要安全地赋值,我们可以做h.dig(:data,:user)&.[]=(:value,"Bob")#orequivalentlyh.dig(:data,:user)&.store(:value,"Bob")但是有更好的方法吗? 最佳答案