I have a gem installed but require 'gemname' does not work. Why?

前端 未结 11 1804
傲寒
傲寒 2020-12-14 00:02

The question I\'m really asking is why require does not take the name of the gem. Also, In the case that it doesn\'t, what\'s the easiest way to find the secret incantation

11条回答
  •  旧巷少年郎
    2020-12-14 00:24

    The question I'm really asking is why require does not take the name of the gem.

    Installing a gem gets the files onto your system. It doesn't make any claims as to what those files will be called.
    As laurie points out there are several conventions for how they are named, but there's nothing to enforce that, and many gem authors unfortunately don't stick to them.

    Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!?

    Read the docs for your gem?
    I find googling for rdoc gemname will usually find the official rdocs for your gem, which usually show you how to use it.

    Memcache is perhaps not the best example, as they assume you'll be using it from rails, and the 'require' will have already been done for you, but most other ones I've seen have examples which show the correct 'require' incantations

提交回复
热议问题