rails 3:gems安装成功,但不能在我的应用中使用它们 [英] rails 3: gems installed successfully, but cannot use them in my app

查看:141
本文介绍了rails 3:gems安装成功,但不能在我的应用中使用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个干净安装的rails 3.0.6。我的应用程序运行良好,除了我不能使用所有未与rails 3一起提供的宝石3.所有这些都在gem列表中。例如,使用matthuhiggins-foreigner:

I did a clean install of rails 3.0.6. My app is running fine, except that I cannot use all the gems that didn't come with rails 3. All of them are in gem list. I also have them in Gemfile and have ran bundle install and bundle update.


on rake db:migrate,它抱怨
没有定义add_foreign_key。

upon rake db:migrate, it complains that add_foreign_key is not defined.

我有同样的问题:


no .css由.less生成)

no .css generated from .less)

geokit-rails3:

geokit-rails3:


未知密钥:

Unknown key(s): origin, within

gem哪些geokit-rails3返回:

gem which geokit-rails3 returns:

/Library/Ruby/Gems/1.8/gems/geokit-rails3-0.1.3/lib/geokit-rails3.rb


$

gem environment returns:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.5.0
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/administrator/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

我很长时间以来一直在研究这个问题。请帮忙!
Thanks!

I have looked into this problem for a long time. Please help! Thanks!

推荐答案

Rails 3不加载没有列在Gemfile中的任何宝石,即使它们是安装在你的系统上。您需要首先明确列出它们。

Rails 3 does not load any gems that are not listed in your Gemfile, even if they are installed on your system. You need to explicitly list them there first.

R3中的典型工作流程不是安装您的宝石,然后使用它们,而是在Gemfile中编写条目,然后安装他们通过安装带有gem install bundle的捆绑软件并通过捆绑安装获得所有剩余的宝石。 Bundle安装将安装您尚未拥有的所有必需宝石,但会使用您所拥有的宝石。

The typical workflow in R3 is not to install your gems and then use them, but to write entries in the Gemfile and then install them by installing bundler with "gem install bundle" and getting all the remaining gems with "bundle install". Bundle install will install any required gems you do not already have, but will use the ones you do have.

(其他用户建议的套件更新会将您的所有宝贝宝石到符合您的要求的最新版本,即使已安装的版本满足要求)。即如果你需要foo_gem> = 1.0并且安装了foo_gem 1.0.1,bundle install不会改变它,但是bundle update会安装foo_gem 1.0.3(如果可用的话)。

(Bundle update, suggested by another user, will bump all your gems to the most recent available version that matches your requirements as laid out in the Gemfile, even if the ones already installed satisfy the requirements). i.e. if you need foo_gem >= 1.0 and you have foo_gem 1.0.1 installed, "bundle install" won't change it but "bundle update" will install foo_gem 1.0.3 if it's available.

如果您正在处理多个具有冲突(或潜在冲突)的应用程序,那么我建议您了解RVM并为每个项目创建一个gemset。如果您仍然在与您的R3项目一起工作任何Rails 2.x项目,这尤其有价值。

If you are working on multiple applications that have conflicting (or potentially conflicting) gems, then I recommend learning about RVM and creating a gemset for each project. This is especially valuable if you are still working on any Rails 2.x projects alongside your R3 projects.

这篇关于rails 3:gems安装成功,但不能在我的应用中使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆