What does ::Base part mean in Person < ActiveRecord::Base class declaration? I'm new to ruby and from what I've gathered so far, Person < ActiveRecord should be used. Thank you.
+4
A:
in Ruby, ::
accesses static class or module constants. ActiveRecord::Base
indicates that the ActiveRecord
class or module has a static inner class called Base
that you're extending.
Edit: as Mike points out, in this case ActiveRecord
is a module...
Dan Vinton
2008-12-01 12:41:13
ActiveRecord is defined as a module in Rails, http://github.com/rails/rails/tree/master/activerecord/lib/active_record/base.rb
Mike Breen
2008-12-01 12:43:42
+6
A:
::Base is a class in module ActiveRecord. One of the things modules do is provide namespacing in Ruby. In Ruby you don't inherit from a module but you can mix it in using the include statement.
May I suggest picking up the Pickaxe book or reading Why's (Poignant) Guide to Ruby.
Mike Breen
2008-12-01 12:42:12
Mike, thanks,I really need to pick up the pickaxe, pun intented ;-)
Valentin Vasiliev
2008-12-01 12:49:20