views:

129

answers:

2

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
ActiveRecord is defined as a module in Rails, http://github.com/rails/rails/tree/master/activerecord/lib/active_record/base.rb
Mike Breen
+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
Mike, thanks,I really need to pick up the pickaxe, pun intented ;-)
Valentin Vasiliev
you're welcome. good luck!
Mike Breen