jjzjj

color_code_string

全部标签

ruby - 杰基尔服务错误 : no implicit conversion of nil into String

我用这个错误搜索了jekyll。jekyll处理页面时似乎出现了ruby​​错误,但我根本不了解ruby​​。杰基尔版本1.3.1我什至重新安装了ruby​​和jekyll,但结果没有改变。更新:在我将jekyll从1.31降级到1.20后,这个错误消失了注意:我的网站是用jekyll1.20创建的,所以它不能用1.3.1构建?这是核心问题吗?E:\GitHub\sample>jekyll服务--trace:Configurationfile:E:/GitHub/sample/_config.ymlSource:E:/GitHub/sampleDestination:E:/GitHub

ruby - 为什么 `Symbol#match` 的行为与 `String#match` 和 `Regexp#match` 不同?

String#match和Regexp#match在匹配成功时返回一个MatchData:"".match(//)#=>#//.match("")#=>#//.match(:"")#=>#但是Symbol#match返回匹配位置(如String#=~)::"".match(//)#=>0为什么Symbol#match表现不同?有用例吗? 最佳答案 我将其报告为Ruby核心中的错误:https://bugs.ruby-lang.org/issues/11991.让我们看看他们会怎么说。更新被质疑的行为似乎是一个错误。似乎从Ruby2.

ruby-on-rails - 如何防止错误 "code converter not found (UTF-8)"?

我在生产环境(CentOS5.6)中遇到此错误,但在开发环境(Ubuntu11.04)中运行良好。在这两种环境中,该应用程序都使用Ruby1.9.3和Rails3.0.9,并由passenger和nginx提供服务。我的Mechanizegem版本是2.3。未找到代码转换器(UTF-8)此代码的最后一行触发它:mech=Mechanize.newpage=mech.get("http://myurl.com/login.php?login_name=a&password=b")form=page.form_with(:name=>"loginForm")form.field_with(

ruby-on-rails - 类型错误 : wrong argument type String (expected Module)

我有以下代码:classProfileLookup基本上包含大量查找数据,按类别拆分。目的是为数据库中的每个类别创建一个方法。通过Rails控制台,此代码按预期工作:ruby-1.9.3@hub:002>ProfileLookup.available_gendersProfileLookupLoad(0.6ms)SELECT"profile_lookups".*FROM"profile_lookups"WHERE"profile_lookups"."category"='gender'ORDERBYvalue=>["Female","Male"]但是,我的规范不合格。以下规范:requ

ruby 正则表达式 : "capture string unless it is followed by..."

我的正则表达式捕获引用的短语:"([^"]*)"我想通过忽略引号来改进它,引号后跟',-'(按此特定顺序排列的逗号、空格和破折号)。我该怎么做?测试:http://rubular.com/r/xls6vN1w92 最佳答案 这应该可以做到,使用NegativeLookahead:"(?!,-)([^"]*)"(?!,-)有点恶心,但它有效。您要确保引号后面没有跟您的字符串,否则匹配将从结束引号开始。http://rubular.com/r/yFMyUKJOHL 关于ruby正则表达式:"

ruby-on-rails - 运行 Heckle 时出错? `current_code' : undefined method `translate' for Ruby2Ruby

我正在尝试运行Heckle,但一直出现错误:>specspec/controllers/my_controller_spec.rb--heckleMyController!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!exception=hasathickskin.There'snothingtoheckle.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(Runsthroughseveralmu

ruby-on-rails - Rails 和 I18n : localized templates vs localized string

您可能知道,从Rails2.2开始,Rails附带了一个简单的本地化和国际化后端。默认情况下,您可以将需要翻译的字符串存储在config文件夹中的本地化文件中。config/locales/en.ymlconfig/locales/it.yml但是Rails也提供了本地化模板和局部的能力。例如,MainController#index操作可以根据模板文件名和当前区域设置选择本地化模板。apps/views/main/index.it.html.erbapps/views/main/index.en.html.erb当您需要翻译单个字符串或短段落时,第一个功能很有用。当同一Action根

ruby-on-rails - 如何从 Visual Studio Code 运行和调试 Ruby on Rails?

如何使用内置的VisualStudioCode启动/调试功能启动RubyonRails?如何修复Debuggerterminalerror:Processfailed:spawnrdebug-ideENOENT错误? 最佳答案 设置和启动安装VSCodeRubyplugin(在macOS上按⌘+⇧+P或ctrl+⇧+P别处并在提示中输入extinstall,然后搜索ruby)安装一些必需的Rubygemgeminstallruby-debug-idegeminstalldebase添加launchconfiguration在Visu

Ruby Date 1 个月前到 String

我需要在Ruby中计算从今天起1个月的日期,并将其转换为String格式:yyyy-dd-mmThh:MM:ss(e.g.2014-08-26T00:00:00)我试过:(DateTime.now-Date.today.prev_month).to_datetime.strftime("%FT%T")但我得到一个方法不存在的异常。 最佳答案 试试这个:require'date'd=Date.today.prev_month#orDate.today.next_month,dependingwhatyouwant=>#d.strfti

ruby-on-rails - 带分号的字符串在 RubyMine 中产生 "unterminated string meets end of file"

在RubyMine调试器中,只需在watch中输入:';'或";"我收到错误:"unterminatedstringmeetsendoffile"这是为什么?据我所知,它不会发生在Rails控制台中,并且与RubyMine没有任何关系。 最佳答案 这是Ruby调试器与Ruby解释器具有不同解析规则的结果。事实上,从irb或ruby命令调用的常规Ruby调试器表现出相同的行为。然而,解决方法很简单:要创建一个由单个分号组成的字符串文字,只需使用反斜杠将其转义即可:$irb>require'debugger'=>true>debugge