Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

::Base part meaning in ActiveRecord::Base

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.

like image 646
Valentin V Avatar asked Dec 01 '08 12:12

Valentin V


People also ask

What is ActiveRecord in Ruby on Rails?

Active Record is the M in MVC - the model - which is the layer of the system responsible for representing business data and logic. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database.

Is ActiveRecord an ORM?

ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code. When you need to make changes to the database, you'll write Ruby code, and then run "migrations" which makes the actual changes to the database.

What is ORM in Ruby on Rails?

ORM is Object Relational Mapper. It means you don't have to manually call the database yourself; the ORM handles it for you. Ruby on Rails uses one called ActiveRecord, and it's a really good one. ORM allows you to do things such as: User. find(50).contacts.


1 Answers

::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.

like image 184
Mike Breen Avatar answered Oct 19 '22 04:10

Mike Breen