Tag: rubygems

猴子修补Devise(或任何Rails gem)

我在我的Rails项目中使用Devise身份validationgem,我想更改它在闪存警报中使用的密钥。 (设计使用:通知和:警告闪存键,但我想将它们更改为:成功和:错误,以便我可以使用Bootstrap显示漂亮的绿色/红色框。) 所以我希望能够以某种方式覆盖set_flash_message中的set_flash_message方法。 这是新方法: def set_flash_message(key, kind, options = {}) if key == ‘alert’ key = ‘error’ elsif key == ‘notice’ key = ‘success’ end message = find_message(kind, options) flash[key] = message if message.present? end 但我只是不知道该把它放在哪里。 更新: 基于答案,我使用以下代码创建了config / initializers / overrides.rb文件: class DeviseController def set_flash_message(key, kind, options = {}) if key == ‘alert’ key […]

在Ubuntu 14.04上安装Jekyll

我在Ubuntu上安装Jekyll时遇到了一些问题。 以下是我的一些版本: trevor~$ ruby -v ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux] trevor~$ gem -v 2.5.1 trevor~$ rvm -v rvm 1.26.11 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/] 但是,当我尝试安装Jekyll时,我收到以下错误: trevor~$ gem install jekyll Building native extensions. This could take a while… ERROR: Error installing jekyll: ERROR: Failed to build gem native extension. current directory: […]

无法在ruby中使用openssl

我在我的虚拟机ubuntu12.04lts中安装了openssl。 当我运行gem命令时,它会出错。 错误:执行gem时(Gem :: Exception) 无法要求openssl。 安装openSSL并重建ruby(首选)或使用非HTTPs源 我还测试了irb模式下的openssl。 它给出了错误。 Loaderror:无法加载此类文件–openssl 来自/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55`requiret’ 我有openssl $openssl version OpenSSL 1.0.1 14 mar 2012 如何修复错误?

编译器无法生成可执行文件。 (RuntimeError)

我最近升级到OS Mountain Lion。 我正在处理的项目需要gem sys-proctable作为依赖项,但是当我运行bundle install我得到: Fetching gem metadata from https://rubygems.org/……… . . . Installing sys-proctable (0.9.2) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /Users/mgriffel/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for rb_pid_t in ruby.h… *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check […]

无法访问RubyGems – 可能是由于SSL?

这里有新的Ruby on Rails,只是尝试安装和设置。 我正在按照本指南开始如何入门。 但是,当我进入3.2创建博客应用程序时,我在运行rails new blog时遇到了一个问题。 当我尝试这个时,我得到一个错误 安装rake 10.4.2时发生错误,Bundler无法继续。 在捆绑之前确保’gem install rake -v ’10 .4.2”成功。 所以,当我尝试运行该命令时,我收到此错误: 错误:找不到有效的gem’rake’:无法从https://rubygems.org/下载数据 – SSL_connect返回= 1 errno = 0 state = SSLv3读取服务器证书B:证书validation失败 谷歌搜索后,我找到了这个指南 。 在诊断部分,我尝试运行openssl version ,但没有用。 我安装了OpenSSL并将其添加到我的路径中。 但是,当我尝试获取任何gem时,我仍然会遇到同样的错误。 我也无法ping ruby​​gems.org – 什么都没有回来。 我使用的是Windows 7,Rails 4.1.8,Ruby 2.0.0p598,RubyGems 2.0.14和OpenSSL 1.01j。 任何帮助将不胜感激!

为什么gems安装在一个目录中,其Ruby版本与我正在运行的版本不同?

当我安装gem时,它被安装在一个名为1.9.1的目录中,尽管它不是我安装的Ruby版本: $ ruby -v ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0] $ gem which rails …/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails.rb 为什么会这样? 我没有安装其他Ruby版本(当然不是v1.9.1)。

如何要求在rails之外工作的活动记录

我需要活动记录,但我在rails之外工作(这就是为什么: 简单的Ruby输入validation库 )。 我需要整个rails gem,还是我可以DRYer?

自动加载常量用户时检测到循环依赖性

我已经按照本教程( http://railscasts.com/episodes/236-omniauth-part-2 )使用OmniAuth和Devise创建facebook登录,我收到此错误:在我的路由中自动加载常量用户时检测到循环依赖性。 RB devise_for :users , :controllers => {:registrations => ‘registrations’} registrations_controller.rb Class RegistrationsController < Devise::RegistrationsController def create super session[:omniauth] = nil unless @user.new_record? end private def build_resource(*args) super if session["devise.omniauth"] @user.apply_omniauth(session["devise.omniauth"]) session["devise.omniauth"] = nil end end end 这是来自AuthenticationsController的我的创建方法 def create omniauth = request.env[“omniauth.auth”] authentication = Authentication.find_by_provider_and_uid(omniauth[‘provider’], omniauth[‘uid’]) if authentication flash[:notice] = “Signed in […]

ROR +无法安装tiny_tds

在这里,我试图从MS-SQL Server 2008获取数据到Ubuntu 10上的我的Rails应用程序。但是我无法安装tiny_tds 。 我按照github给出的步骤进行操作。 但没有回应。 请指导我正确设置。 使用gem命令:: gem install tiny_tds 这个命令也是:: gem install tiny_tds –with-freetds-include=/usr/local/include/freetds –with-freetds-lib=/usr/local/lib 错误: Installing tiny_tds (0.4.5) with native extensions /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions’: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /home/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb looking for library directory /home/.rvm/gems/ruby-1.9.2-p180@rails3/lib … no looking for library directory /home/.rvm/gems/ruby-1.9.2-p180@rails3/lib/freetds … no […]

BUG Bus Error ruby​​ 1.8.7

我在使用Xcode 4.2 GM(新MacBook)在Lion 10.7.1上使用RVM编译Ruby 1.8.7后出现错误。 它编译得很好但是当我尝试安装任何gem我得到以下内容: gem install bundler /Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Bus Error ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0] Abort trap: 6 更新 :最后我希望安装Xcode 4.2,安装了Ruby 1.8.7,1.9.x的RVM,并且一切正常。