Hi! I''m observing some problems using gem inside Rails. My understanding is that after following sequence in irb: $ irb irb(main):001:0> require ''rubygems'' => true irb(main):002:0> require ''active_record'' => true irb(main):003:0> gem ''acts_as_taggable'' => true I should have access to acts_as_tagable mixins, like: irb(main):005:0> ActiveRecord::Acts::Taggable NameError: uninitialized constant ActiveRecord::Acts::Taggable from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:263:in `load_missing_constant'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing'' from (irb):5 Well it looks like I don''t have access. I have to include file from gem manually: irb(main):013:0> require ''/usr/local/lib/ruby/gems/1.8/gems/acts_as_taggable-2.0.2/lib/taggable.rb'' => [] irb(main):014:0> ActiveRecord::Acts::Taggable => ActiveRecord::Acts::Taggable What I''m doing wrong? My environment: $ ruby --version ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-freebsd6] $ gem list rubygems-update rubygems-update (0.9.2) Best regards, -- Witold Rugowski http://nhw.pl/wp/ (EN blog) http://nhw.pl/pl/ (PL blog) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Witold, That is an enhancement of the latest rubygems. The ''gem'' method does not trigger auto-require as ''require_gem'' used to. The ''acts_as_taggable'' gem has autorequire set to ''taggable'', which activates all that stuff you expect. But since it is not called when you use ''gem'', you need to require ''taggable'' explicitly after that. Notice, that there is no need to specify the full path in require. Hope it helps, Val $ irb -rrubygems>> gem ''acts_as_taggable''=> true>> require ''taggable''=> true>> ActiveRecord::Acts::Taggable=> ActiveRecord::Acts::Taggable On Apr 22, 8:31 pm, Witold Rugowski <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi! > > I''m observing some problems using gem inside Rails. My understanding is > that after following sequence in irb: > > $ irb > irb(main):001:0> require ''rubygems'' > => true > irb(main):002:0> require ''active_record'' > => true > irb(main):003:0> gem ''acts_as_taggable'' > => true > > I should have access to acts_as_tagable mixins, like: > > irb(main):005:0> ActiveRecord::Acts::Taggable > NameError: uninitialized constant ActiveRecord::Acts::Taggable > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:263:in > `load_missing_constant'' > from > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in > `const_missing'' > from (irb):5 > > Well it looks like I don''t have access. I have to include file from gem > manually: > > irb(main):013:0> require > ''/usr/local/lib/ruby/gems/1.8/gems/acts_as_taggable-2.0.2/lib/taggable.rb'' > => [] > irb(main):014:0> ActiveRecord::Acts::Taggable > => ActiveRecord::Acts::Taggable > > What I''m doing wrong? My environment: > > $ ruby --version > ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-freebsd6] > $ gem list rubygems-update > rubygems-update (0.9.2) > > Best regards, > > -- > Witold Rugowskihttp://nhw.pl/wp/(EN blog)http://nhw.pl/pl/(PL blog) > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Val wrote:> That is an enhancement of the latest rubygems. The ''gem'' method does > not trigger auto-require as ''require_gem'' used to. The > ''acts_as_taggable'' gem has autorequire set to ''taggable'', which > activates all that stuff you expect. But since it is not called when > you use ''gem'', you need to require ''taggable'' explicitly after that.Thank You for clarifications. Is there some way to enable old behavior? Well, I see this as something lowering code readability. Thanks to disabled auto require feature I need to execute two commands, and require often would need different name for include (like in this example: acts_as_taggable and taggable) -- Witold Rugowski http://nhw.pl/wp/ (EN blog) http://nhw.pl/pl/ (PL blog) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Witold Rugowski wrote:> Val wrote: >> That is an enhancement of the latest rubygems. The ''gem'' method does >> not trigger auto-require as ''require_gem'' used to. The >> ''acts_as_taggable'' gem has autorequire set to ''taggable'', which >> activates all that stuff you expect. But since it is not called when >> you use ''gem'', you need to require ''taggable'' explicitly after that. > > Thank You for clarifications. > > Is there some way to enable old behavior? Well, I see this as something > lowering code readability. Thanks to disabled auto require feature I > need to execute two commands, and require often would need different > name for include (like in this example: acts_as_taggable and taggable)gem "somegem" is - if I understand correctly - only needed if you need a special version require "somegem" will require the latest "somegem" irb(main):001:0> require "rubygems" => true irb(main):002:0> require "trollop" => true irb(main):003:0> Trollop::VERSION => "1.6" --- irb(main):001:0> require "rubygems" => true irb(main):002:0> gem "trollop", "1.4" => true irb(main):003:0> require "trollop" => true irb(main):004:0> Trollop::VERSION => "1.4" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---