升级到ruby 2.3.0 NameError:uninitialized constant I18n :: Config :: Backend

我刚刚将Ruby 2.2.2升级到2.3.0。 每当我运行rake任务时,我都会收到以下错误: Christians-Air:my_rails_app cman77$ rake –trace rake aborted! NameError: uninitialized constant I18n::Config::Backend /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n/config.rb:19:in `backend’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n.rb:147:in `translate’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/actionview-4.2.6/lib/action_view/helpers/translation_helper.rb:69:in `translate’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n/config.rb:19:in `backend’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/i18n-0.7.0/lib/i18n.rb:147:in `translate’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/actionview-4.2.6/lib/action_view/helpers/translation_helper.rb:69:in `translate’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `block in run_tasks_blocks’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `each’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `run_tasks_blocks’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/application.rb:452:in `run_tasks_blocks’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:453:in `load_tasks’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/railtie.rb:194:in `public_send’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/railties-4.2.6/lib/rails/railtie.rb:194:in `method_missing’ /Users/cman77/Dropbox/rails_projects/my_rails_app/Rakefile:9:in `’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile’ /Users/cman77/.rvm/gems/ruby-2.3.0@jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling’ […]

Ruby – 列表减去

我有两个清单 a = [1, 2, 3, 4, 1, 2] b = a.uniq # b = [1, 2, 3, 4] c = a – b 结果得到c = [] 我期望结果c = [1, 2] 我怎么能得到这个?

如何在最接近的时间段内选择前280个单词?

我需要从较长的单词中提取指定数量单词的较短段文本。 我可以这样做 text = “There was a very big cat that was sitting on the ledge. It was overlooking the garden. The dog next door watched with curiosity.” text.split[0..15].join(‘ ‘) >>””There was a very big cat that was sitting on the ledge. It was overlooking” 我想选择下一期的文本,所以我最终不会得到部分句子。 是否有一种方法可能使用正则表达式来完成我正在尝试做的事情,这将能够使文本达到并包括在第15个单词之后最接近的下一个时期?

如何在下拉菜单中将每个选项与关联simple_form调用相关联?

我使用simple_form插件有这个表单: true) do |f| %> @video.comment_titles, :label => “Comment Title:”, :include_blank => false %> false, :placeholder => “Post a comment.” %> “Post” %> 这将创建一个包含此行的下拉列表: @video.comment_titles, :label => “Comment Title:”, :include_blank => false %> 我的问题是你如何修改这段代码,以便每个下拉项目都是每个comment_title的个人展示视图的链接? UPDATE 这是从第一个答案的代码生成的html: #<CommentTitle:0x10353b890>”>#<CommentTitle:0x10353b890> #<CommentTitle:0x1035296e0>”>#<CommentTitle:0x1035296e0> #<CommentTitle:0x1035295a0>”>#<CommentTitle:0x1035295a0>

有没有办法在rails中停止此默认插入

好的,我有这个数据结构 class User :positions has_many :positions class Company :positions class Position < ActiveRecord::Base belongs_to :company belongs_to :user attr_accessible :company_id, :user_id, :regular_user end 和我的数据库结构 create_table “positions”, :force => true do |t| t.integer “company_id” t.integer “user_id” t.datetime “created_at”, :null => false t.datetime “updated_at”, :null => false t.boolean “regular_user”, :default => true end 如果我向用户公司添加另一家公司,则regular_user标志始终设置为true 1.9.3-p125 :013 > @user.companies […]

用Ruby读取前一行文件

如何阅读文件的主流行。 与IO.gets.I相反,我最初认为将IO.lineno设置为我想要读取的行号,但这并不像预期的那样工作。 你怎么读实际上一行?

Ruby regex:从字符串中提取url列表

我有一串图像的URL,我需要将其转换为数组。 http://rubular.com/r/E2a5v2hYnJ 我该怎么做呢?

MySQL2 / Ruby 1.9.3 / Rails上的分段错误3.2

我一直很难让rails 3.2与mysql2一起工作。 我正在运行OSX 10.6,MySQL 5.1.37 我正在获得这个可爱的堆栈跟踪。 HunterMBP:v hunter$ bundle exec rake db:create /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: [BUG] Segmentation fault ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0] — Control frame information ———————————————– c:0033 p:-543968548 s:0099 b:0099 l:000098 d:000098 TOP c:0032 p:—- s:0097 b:0097 l:000096 d:000096 CFUNC :require c:0031 p:0107 s:0093 b:0093 l:000092 d:000092 TOP /Users/hunter/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.2/lib/mysql2.rb:8 c:0030 p:—- s:0091 b:0091 l:000090 […]

Rails 3 ActiveRecord每个关联模型的模型总和

我有2个型号 Category – id – name 和 Transaction – id – category_id – amount 我想找到每个类别的所有交易的总和。 我知道我可以获得一个caterogies列表,然后使用category_id得到所有交易的总和,但它会做20多个查询。 有没有办法在一个查询中完成所有操作? 编辑:我想最终得到[[category1,sum],[category2,sum]]的列表。

function编程风格与Ruby中的性能

我喜欢函数式编程,我也喜欢Ruby。 如果我能够以function样式而不是命令式样式编写算法,我会这样做。 我倾向于不尽可能地更新或重用变量,避免使用“爆炸!” 方法和使用“map”,“reduce”和类似的函数而不是“each”或危险循环等。基本上我尝试遵循本文的规则。 问题是通常function性解决方案比命令式解决方案慢得多 。 在这篇文章中有一些清晰而可怕的例子,在某些情况下要慢15-20倍。 阅读它并做一些基准后,我害怕继续使用function样式,至少在Ruby中。 另一方面,我觉得在函数风格中编写代码更舒服,因为它是智能和干净的,它往往更少的错误,我认为更“正确”,特别是现在我们可以使用并发和并行来获得更好的性能。 所以我对Ruby中使用哪种样式感到很困惑。 任何明智的建议将不胜感激。