jjzjj

error-code

全部标签

ruby-on-rails - map(& :name) do in this Ruby code? 是什么意思

为了更好地理解Ruby,我在网上冲浪时遇到了这段代码:require'rubygems'require'activeresource'ActiveResource::Base.logger=Logger.new("#{File.dirname(__FILE__)}/events.log")classEvent"Shortesteventevar!",:starts_at=>1.second.ago,:capacity=>25,:price=>10.00)e.destroy我特别感兴趣的是events.map(&:name)是如何工作的?我看到events是一个数组,因此它调用了它的ma

ruby - "Error validating client secret."404 与 Facebook Oauth 和 ruby

我正在尝试使用warden为应用程序实现facebook身份验证,在用户允许facebook身份验证并使用token重定向到我的应用程序回调后,我在使用api时得到400。我的典狱长策略是这样的:classFacebook'https://graph.facebook.com'enddefparams@params||=Rack::Utils.parse_query(request.query_string)enddefauthorize_urlclient.web_server.authorize_url:redirect_uri=>request.url,:scope=>'emai

ruby-on-rails - 国际化 : error message localization for particular model

我可以为每个验证本地化错误消息,但我如何为特定模型创建错误。普通语言环境看起来像这样:en:mongoid:errors:messages:taken:"Itisalreadytaken"但我想为user模型更改消息:en:mongoid:errors:messages:taken:"Itisalreadytaken"user:taken:"Itisalreadytaken.%{link_to'Rememberpassword',reset_password_path'}" 最佳答案 试试这个:en:mongoid:errors:m

ruby-on-rails - 为什么 PG::UniqueViolation: ERROR: duplicate key value violates unique constraint?

我有一个模型Post,每次创建帖子时,我都希望同时创建一个新的Moderation实例。所以在post.rb中我使用回调after_save:create_moderation然后写一个私有(private)方法:...includeReportableafter_save:create_moderationprivatedefcreate_moderationself.create_moderation!(blog:Blog.first)end但是在创建提案时出现此错误:PG::UniqueViolation:ERROR:duplicatekeyvalueviolatesunique

ruby - 在没有 rvm 或 rbenv 的情况下编译 Ruby 2.0 错误, `readline.c:1886:26: error: ' Function' undeclared (first use in this function)`

我想安装gitlab,不推荐使用任何ruby版本管理器。但是这是我的操作系统Linuxdqa-dev3.13.0-24-generic#46-UbuntuSMPThuApr1019:08:14UTC2014i686i686i686GNU/Linuxlinkingshared-objectpsych.soinstallingdefaultpsychlibrariesmake[2]:Leavingdirectory`/home/poc/ruby-2.0.0-p451/ext/psych'make[2]:Enteringdirectory`/home/poc/ruby-2.0.0-p451/

ruby-on-rails - Rails 3 和加密字符串 Gem - 获取 OpenSSL::Cipher::CipherError: bad decrypt error

我正在使用rails3.2、Ruby1.9.3和encrypted_stringsgem,尝试以下操作:"wC6234sdf234234cCY1Lag==\n".decrypt(:symmetric,:key=>"mykeynottelling")我收到这个错误:OpenSSL::Cipher::CipherError:baddecrypt然而,这不会发生在Ruby1.8.7中。我对此有点迷茫,有人知道是什么原因造成的吗?更新1:如果我在ruby​​1.8.7中加密一个字符串:"password".encrypt(:symmetric,:key=>"www.buyandsell.ie"

ruby-on-rails - 如何修复 PG::DuplicatePstatement: ERROR?

我想知道如何防止此类错误。到目前为止,我尝试通过AWSOpsworks的数据库配置禁用准备好的语句:例如:数据库配置},"deploy":{"app_name":{"database":{"adapter":"postgresql","prepared_statements":false,"username":"username","database":"db_name_production","host":"cool_host.com","password":"easy"},错误日志PG::DuplicatePstatement:ERROR:preparedstatement"a6"

ruby - better_errors 要求 Ruby 版本 >= 2.0.0

Bundle无法安装better_errors。Gem::InstallError:better_errorsrequiresRubyversion>=2.0.0.Anerroroccurredwhileinstallingbetter_errors(2.0.0),andBundlercannotcontinue.Makesurethat`geminstallbetter_errors-v'2.0.0'`succeedsbeforebundling.但是geminstallbetter_errors工作正常。ruby--version表示ruby2.0.0p353(2013-11-22

ruby-on-rails - Rails Engines : When to put code in app, 何时在 lib 中,何时在 vendor 文件夹中?

我正在开发一个Rails引擎,所以我对现有引擎进行了一些研究。我注意到他们中的许多人在app中都有文件,但也在lib和vendor中。我很清楚,我应该将任何应该由主机应用程序替换的代码放入app文件夹中(例如,当有一个模型app/user.rb,主机应用程序可以很容易地拥有自己的app/user.rb文件并使用这个而不是引擎的)。但我不确定,何时必须将内容放入lib,何时放入vendor?我想,在vendor中,我应该只放置我想在我的项目中使用的来自其他开发人员或项目的“外部”代码,而在lib中,我放置我的拥有我在项目中实际使用的其他库。但是,例如,为什么WiceGrid将内容放入其w

ruby-on-rails - ActiveRecord::Errors 的 Rails 3 替代品是什么?

ActiveRecord::Errors的Rails3替代品是什么?在Rails2.3.8中,这是一个对象:>>ActiveRecord::Errors=>ActiveRecord::Errors在Rails3.0.0rc中,你会得到一个NameError:>>ActiveRecord::ErrorsNameError:uninitializedconstantActiveRecord::Errorsfrom(irb):2我正在尝试制作wizardly生成器与Rails3一起工作。$railsgwizardly_scaffoldhome但失败了:/Library/Ruby/Gems/1