On Sat, Mar 03, 2007 at 08:55:40PM -0800, snacktime
wrote:> Trying to figure out why require_gem works and gem doesn''t. using
> just gem, I get uninitialized constant ActiveRecord (NameError). Use
> require_gem and it works, but tells me that require_gem is obsolete.
>
> require ''rubygems''
> gem ''activerecord''
>
> def connect(environment)
> conf = YAML::load(File.open(File.dirname(__FILE__) +
''/config/database.yml''))
> ActiveRecord::Base.establish_connection(conf[environment])
> end
>
> connect(''development'')
require_gem was a wrapper around require that accepted an optional second
argument to specify a version constraint.
the new gem method is not a wrapper around require. it simply registers a
version constraint on the named gem. when you subsequently call require, that
version constraint is verified.
so if you just want to require activerecord and you don''t care what
vesrion,
just do require ''activerecord''. otherwise, use the gem method
first to
specify which versions.
of course, you still have to require ''rubygems'' first if you
want to require
a gem, whether you want to specify a specific version constraint or not.
marcel
--
Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---