Hi -- I''m confused what :lib in config.gem(). When do I need it to specify? What should I specify? I know that I need to put the name of the library, but the name is always the same with the gem name? Also do I need to add "require ''the_library''" when I actually use it somewhere in Rails? Or does the config.gem() runs "require" statement as well? Sorry for the stupid questions. - Jon
Hi Jon, rails automatically requires a gem loaded by config.gem. how does rails know what to require? That''s what you specify with :lib. If you do not specify :lib, rails tries to require the name of the gem. so, for example requiring the simple-navigation gem: config.gem ''simple-navigation'' tries to require ''simple-navigation'', which does not work, so you have to specify config.gem ''simple-navigation, :lib => ''simple_navigation'' - Andi On Oct 11, 8:07 am, Hunt Jon <jona.hunt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi -- I''m confused what :lib in config.gem(). > > When do I need it to specify? > What should I specify? I know that I need to put the name of the > library, but the name is always the same with the gem name? > > Also do I need to add "require ''the_library''" when I actually use it > somewhere in Rails? Or does the config.gem() runs "require" statement > as well? > > Sorry for the stupid questions. > > - Jon
Hi Jon, Another instance where you will need to explicitly use the :lib option is for gems you download and install from GitHub, where gem names are typically prefixed with the author''s name:> config.gem "greatseth-mediainfo", :lib => ''mediainfo''Peter On 11 Oct 2009, at 10:54, Andi Schacke wrote:> > Hi Jon, > > rails automatically requires a gem loaded by config.gem. how does > rails know what to require? That''s what you specify with :lib. If you > do not specify :lib, rails tries to require the name of the gem. > > so, for example requiring the simple-navigation gem: > > config.gem ''simple-navigation'' > > tries to require ''simple-navigation'', which does not work, so you have > to specify > > config.gem ''simple-navigation, :lib => ''simple_navigation'' > > - Andi > > On Oct 11, 8:07 am, Hunt Jon <jona.hunt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi -- I''m confused what :lib in config.gem(). >> >> When do I need it to specify? >> What should I specify? I know that I need to put the name of the >> library, but the name is always the same with the gem name? >> >> Also do I need to add "require ''the_library''" when I actually use it >> somewhere in Rails? Or does the config.gem() runs "require" statement >> as well? >> >> Sorry for the stupid questions. >> >> - Jon > >
Peter Vandenberk wrote:> Hi Jon, > > Another instance where you will need to explicitly use the :lib option > is for gems you download and install from GitHub, where gem names are > typically prefixed with the author''s name: > >> config.gem "greatseth-mediainfo", :lib => ''mediainfo'' > > PeterWhat about :lib false? I read somewhere that by using this the gem doesn''t actually load or something? I read this here: http://szeryf.wordpress.com/2009/03/07/finally-getting-gettext-to-work-with-rails-22/#comment-1013. Can someone explain this please? Thanks in advance! -- Posted via http://www.ruby-forum.com/.
On Sat, Oct 10, 2009 at 11:07 PM, Hunt Jon <jona.hunt777-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi -- I''m confused what :lib in config.gem(). > > When do I need it to specify? > What should I specify? I know that I need to put the name of the > library, but the name is always the same with the gem name? > > Also do I need to add "require ''the_library''" when I actually use it > somewhere in Rails? Or does the config.gem() runs "require" statement > as well? > > Sorry for the stupid questions. >In short, if the gem name differs from the library name that one would require, then you''ll need to tell Rails by specifying the name of this library like config.gem "gem-name", :lib => "lib-name" For example, config.gem "sqlite3-ruby", :lib => "sqlite3" config.gem "aws-s3", :lib => "aws/s3" Good luck, -Conrad> > - Jon > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 29 Oct 2009, at 07:37, Lenart Rudel wrote:> What about :lib false? I read somewhere that by using this the gem > doesn''t actually load or something? I read this here: > http://szeryf.wordpress.com/2009/03/07/finally-getting-gettext-to-work-with-rails-22/#comment-1013 > . > Can someone explain this please?It''s basically as the poster say:> this ensures they are installed, but will not load themWhen you bootstrap the Rails environment (server, console, runner, etc.) it won''t "require" any gems that have ":lib => false" specified, but Rails still "knows" about these gems, so things like "rake gems:install" still work as expected. Hope this helps, Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.