Tag: ruby on rails 3

CSR失败:错误解析请求ASN1错误标记值已满足(ASN:267 CRYPT_E_ASN1_BADTAG)

我试图通过以下方式提交CSR请求: require ‘openssl’ require ‘json’ def public_key_info key_info = private_key.public_key.to_pem key_info = key_info.sub! ‘—–BEGIN PUBLIC KEY—–‘, ‘—–BEGIN CERTIFICATE REQUEST—–‘ key_info = key_info.sub! ‘—–END PUBLIC KEY—–‘, ‘—–END CERTIFICATE REQUEST—–‘ key_info end # “Creating a new 2048bit RSA Keypair…” def private_key @private_key = OpenSSL::PKey::RSA.new 2048 end payload = { “CsrData” => public_key_info, “certTemplate” => “MyTemplate” } encoded […]

耙子流产了! 无法在El Capitan上加载这样的文件 – mysql2 / mysql2

我在过去两周内一直在尝试在Mac上设置我的代码。 以前我使用的是Ubuntu,设置代码从未如此困难。 我几乎遵循了所有教程,但没有运气。 请任何人都可以指导我在mac上设置RoR。 在完成所有教程后,我最终只得到了mysql错误。 rake aborted! cannot load such file — mysql2/mysql2 /Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require’ /Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require’ /Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency’ /Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require’ /Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require’ /Users/sahil/.rvm/gems/ruby-1.9.3-p551@global/gems/bundler-1.10.6/lib/bundler.rb:134:in `require’ /Users/sahil/Documents/work/ccprod/config/application.rb:9:in `’ /Users/sahil/Documents/work/ccprod/Rakefile:4:in `’ (See full trace by running task […]

Rails抛出“REXML :: ParseException没有有效的根”exception

我有一个JavaScript对象,并使用Douglas Crockford的JSON实用程序将其转换为JSON。 在发送后AJAX请求时,我得到: REXML :: ParseException没有有效的根 REXML::ParseException (The document “{\”name\”:\”asda\”,\”deadline\”:\”May 24, 2011\”}” does not have a valid root): 我无法继续此错误。

Gem Rmagick安装错误:extconf.rb:171:在“’:没有这样的文件或目录 – convert -version(Errno :: ENOE NT)

我在安装rmagick时遇到此错误,我已经遵循了所有类型的指南并且每次都得到相同的错误。 这次我遵循了以下指南: http : //www.youtube.com/watch?v = gEWAVlNCKhg& feature = yourout.be : C:/Ruby192/bin/ruby.exe extconf.rb –with-opt-include=C:/ImageMagick/Sou rceCode –with-opt-lib=C:/ImageMagick checking for Ruby version >= 1.8.5… yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided […]

Rails3 Active Admin:如何在首次点击Shipments标签时仅显示打开状态记录?

我正在使用ActiveAdmin。 我有一份包含打开和关闭状态(作为字符串)的货件清单。 当用户点击“货件”选项卡时,我只想显示“打开”货件。 我怎样才能做到这一点? 当然,用户以后可以选择使用filter查看已关闭的货件。 但我希望默认情况下最初只显示Open货件。

如何为开发和生产指定不同版本的gem

我需要有不同版本的gem用于开发和生产,所以我将以下内容放在我的gemfile中。 group :development, :test do gem ‘rspec-rails’, ‘2.11.0’ gem ‘bcrypt-ruby’, ‘3.1.2’ end group :production do gem ‘rails_12factor’ gem ‘bcrypt-ruby’, ‘3.0.1’ end 但如果我尝试bundle install甚至只是rails console我得到上述错误 我试过了 bundle install –without production 但我仍然收到错误消息。 仅供参考:我需要这样做,因为我要通过rails教程,在windows,ruby 2.0.0和bcrypt以及Heroku之间出现冲突,所以我在windows上使用bcrypt 3.1.2(对活动进行了修改)在Heroku上记录gemfile)和bcrypt 3.0.1。 有关更多详细信息,请参阅此内容: 在Windows上使用带有ruby2.0的bcrypt 3.0.1的问题 我基本上完成了第一个答案中提到的内容 编辑 ################################################################### 正如下面的答案所指出的,我真的应该在生产和开发中使用相同的版本(即使我只是在教程中工作)。 我最终做的是猴子修补ActiveModel使用 gem ‘bcrypt-ruby’, ‘3.1.2’ 而不是 gem ‘bcrypt-ruby’, ‘~> 3.0.0’ 在secure_password中。 我通过将以下内容放在lib / secure_password_using_3_1_2.rb中来完成此操作 module […]

您的Ruby版本是2.3.0,但您的Gemfile指定为2.1.2

我正在尝试设置现有项目,在运行bundle install ,我遇到了以下错误。 我已经尝试了很多可能的解决方案,但没有为我工作,我也运行建议的命令,如gem pristine bcrypt –version 3.1.10但不适合我。 bipashant@bipashant-Inspiron-5537:~/sanokam$ bundle install Ignoring bcrypt-3.1.10 because its extensions are not built. Try: gem pristine bcrypt –version 3.1.10 Ignoring curb-0.9.3 because its extensions are not built. Try: gem pristine curb –version 0.9.3 Ignoring debug_inspector-0.0.2 because its extensions are not built. Try: gem pristine debug_inspector –version 0.0.2 Ignoring eventmachine-1.0.3 […]

跳过带有扩展名pdf的网页,在Anemone中抓取拉链

我正在使用海葵gem(Ruby-1.8.7和Rails 3.1.1)开发爬虫。 如何从抓取/下载中跳过带有扩展名pdf,doc,zip等的网页。

Rails PostgreSQL数字字段溢出ERROR

我的架构上有一个十进制字段的价格,每次我尝试插入价格时,pg都带有此错误。 谁能给我任何光? 谢谢 组态 t.decimal “price”, :precision => 2, :scale => 2 错误 PG::Error: ERROR: numeric field overflow DETAIL: A field with precision 2, scale 2 must round to an absolute value less than 1. : INSERT INTO “items” (“category_id”, “name”, “price”, “updated_at”) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, […]

如何删除HTML节点之间的空格?

我正在尝试从 标记之间的HTML片段中删除空格 Foo Bar bar bar bar bla 如您所见, 标记之间总是有空格。 问题是在将字符串保存到我的数据库时,空格会创建标记。 像strip或gsub这样的方法只删除节点中的空格,导致: FooBar barbarbar bla 而我想要: Foo Barbar bar barbla 我正在使用: Nokogiri 1.5.6 Ruby 1.9.3 轨道 更新: 偶尔会有 标签的子节点产生同样的问题:之间有空格 示例代码 注意:代码通常在一行中,我重新格式化它,因为它是无法忍受的,否则…… Selling an Appartment beautiful apartment! near the train station . . . 10 minutes away from a shopping mall nice view . . . […]